Re: oauth 2 authentication without user intervention

235 views
Skip to first unread message

Jose Alcérreca (AdSense API Team)

unread,
Oct 18, 2012, 6:23:53 AM10/18/12
to adsen...@googlegroups.com
Hi Mike,

If you store the Refresh Token the first time you authenticate, you can use it to generate new Access Tokens so manual intervention is only needed once. 

If it's only a few accounts, you can carry out this process manually using the OAuth2 Playground:

Cheers,
Jose


---
Jose Alcérreca
Developer Relations

Google UK Limited
Registered Office: Belgrave House, 76 Buckingham Palace Road, London SW1W 9TQ
Registered in England Number: 3977902


Google Inc.| Developer Relations | AdSense API Team | developers.google.com/adsense

Follow us on our Google Ads Developer page on Google+ and our Google Ads Developer Blog to learn more about the different Ads APIs at Google.



On Wednesday, 17 October 2012 00:29:29 UTC+1, Michael Ni wrote:
Since we cannot use the service authentication flow for adsense, I have to use the web application flow.

However, I am requesting from a server to only a few personal accounts.

I do not want the be redirected to google to click "allow".

How can I bypass the "manual process" part of oauth 2 where you have to go to google and get the refresh and access tokens.

Can I programmatically click the accept button or completely bypass this step?

Mike
Message has been deleted

Jose Alcérreca (AdSense API Team)

unread,
Oct 23, 2012, 2:40:41 PM10/23/12
to adsen...@googlegroups.com
Hi Michael,

User authentication/authorization is also only required once. You should give the generated URL to the users and let them grant the authorization. This way you don't have to store passwords.

You can automate this with a set-up process in your page by redirecting users to the URL or you can do it manually, if you don't plan to expand, using a script to generate the URL and sending it to the users and waiting for them to authorize.

This process is only needed once per user, not per session. If you are the only user I would go for the manual option.

Cheers,
Jose

---
Jose Alcérreca
Developer Relations

Google UK Limited
Registered Office: Belgrave House, 76 Buckingham Palace Road, London SW1W 9TQ
Registered in England Number: 3977902


Google Inc.| Developer Relations | AdSense API Team | developers.google.com/adsense

Follow us on our Google Ads Developer page on Google+ and our Google Ads Developer Blog to learn more about the different Ads APIs at Google.


On Tuesday, October 23, 2012 2:03:17 AM UTC+1, Michael Ni wrote:
Jose,

Thanks for your response

Regarding the first time to authenticate, the part where the user authenticates and authorizes with google...

In the examples, the flow is to redirect the user to google and have google send the response to the callback url.

I only know how to implement with this flow requiring a web browser

However my code is on a server and the only user is myself,

How should I authenticate?

Can I authenticate through command line? 

I wish I could use the server application flow but it's not available for adsense.



Mike
Reply all
Reply to author
Forward
0 new messages