Getting account info without refresh token on second "authorization" request.

26 views
Skip to first unread message

James Andrews

unread,
May 11, 2017, 1:29:52 PM5/11/17
to AdWords API Forum
Scenario....

User logs into account on our website, clicks on an adwords product they want to by, they grant us authorization to use their account and we store all their tokens and other data in our system to use.

Weeks later they choose another adwords product and instead of clicking on the saved account we already have stored they click on the link to authorize (we allow this so they can link multiple adwords accounts).  They however choose the account they already authorized.  They go through the authorization process again.  Their token this time does not have a refresh token associated with it so currently we throw an error at them saying they have already authorized.

The problem.  Say said our customer has 10 different adwords accounts for whatever reason.  They don't understand which ones they've already authorized.  What we would like to be able to do is when they authorize the second time get some basic account information that we can use to find their already stored tokens based on an ID.

We can do this with EVERY other google API.  When a customer re-authorizes accidentally we get an access token which gives us the ability to get the google userId so we can look it up in our database and find their token if the refresh_token is no present.

How can I do this with Adwords API?

James



Shwetha Vastrad (AdWords API Team)

unread,
May 11, 2017, 4:18:13 PM5/11/17
to AdWords API Forum
Hi James, 

If you are using Installed application flow, the refresh tokens are always returned. You can prompt the user to re-authorize your app by adding the prompt=consent parameter to the authentication request. When prompt=consent is included, the consent screen is displayed every time the user logs into your app and a refresh token is returned in the response. You can consider using CustomerService.getCustomers() without setting the clientCustomerId to retrieve the details of the authenticated account when users reauthorize. 

Regards,
Shwetha, AdWords API Team.

James Andrews

unread,
May 11, 2017, 4:49:04 PM5/11/17
to AdWords API Forum
Thank you!  That totally did the trick!

Thanks
James
Reply all
Reply to author
Forward
0 new messages