How to use the refresh token?

45 views
Skip to first unread message

john mock

unread,
May 18, 2016, 9:12:06 AM5/18/16
to AdWords API Forum
Hi Everyone, 
First off, I'd like to apologize if this is a silly question but I'm a total Adwords API newbie. I have the rails example project (google-api-ads-ruby/adwords_api/examples/adwords_on_rails/) working and modified it to include offline access in the initial request. I'm saving off the refresh token in my database for each user but I'm not sure what to do from there. After the initial access token expires, my calls to the API are failing with AdsCommon::Errors::OAuth2VerificationRequired . 

Do I manually need to rescue errors from each API call to determine if the access token has expired? 

Once I know the access token has expired, how do I use the refresh token to obtain a new access token?

Thanks in advance for any help!!

Peter Oliquino

unread,
May 18, 2016, 3:04:49 PM5/18/16
to AdWords API Forum
Hi John,

No worries, your question is totally not silly. If you include the client library in your application, it will take care of refreshing the token for you.

Thanks,
Peter
AdWords API Team

john mock

unread,
May 18, 2016, 8:01:45 PM5/18/16
to AdWords API Forum
Thanks Peter! I've been banging my head against the wall on this for some time. It turns out my problem was that I'm using Omniauth and the client ID and client secret set in the Omniauth config file was different than in the adwords_api.yml file. Once I made them both the same, the token is refreshed automatically. 
Reply all
Reply to author
Forward
0 new messages