v201705 Authentication

82 views
Skip to first unread message

Sergiu Obreja

unread,
Jun 13, 2017, 5:15:12 PM6/13/17
to AdWords API Forum
Hello guys!

I'm working on an web application where clients can connect their AW account and get reports. Until now I was using v201607 with OAuth2 and offline access and for each user I was saving the access token and the refresh token... all was working like a charm. Now I'm upgrading to v201705 and the things seem to be a little bit different. I can't manage to access the accounts using the access tokens. In the past I was using this code to get the customers of an account:

if(!$user->GetOAuth2Handler()->IsAccessTokenValid($connectionData))
      $connectionData
= $user->GetOAuth2Handler()->RefreshAccessToken($connectionData);

$user
->SetOAuth2Info($connectionData);

$customerService
= $user->GetService('CustomerService');
$customers
= $customerService->GetCustomers();


How can I do this in v201705?

Peter Oliquino

unread,
Jun 14, 2017, 12:56:10 AM6/14/17
to AdWords API Forum
Hi Sergiu,

Could you provide any error messages or SOAP request and response when you encountered this issue? This will allow me to better identify the cause. Please also reply using Reply privately to author.

Thanks and regards,
Peter
AdWords API Team

Sergiu Obreja

unread,
Jun 14, 2017, 7:18:47 AM6/14/17
to AdWords API Forum
Hi Peter!

The problem is that I don't know how to make the call using the access token and the refresh token I already have.

Thanks!

Peter Oliquino

unread,
Jun 14, 2017, 11:50:08 PM6/14/17
to AdWords API Forum
Hi Sergiu,

The refreshToken that you generated should be stored in your adsapi_php.ini file. If you are using the client library, you will no longer need to worry about your access tokens as they are generated automatically. I would recommend that you follow carefully the PHP client library guide for you to complete your setup.

Best regards,
Peter
AdWords API Team

Sergiu Obreja

unread,
Jun 15, 2017, 5:06:49 AM6/15/17
to AdWords API Forum
Hi,

I already have a refresh token generated based on my client id and client secret that's stored in the .ini file, but what's confusing me is that after logging through a consent screen after I get the code I am redirected back to my page and I get a different refresh_token.

Peter Oliquino

unread,
Jun 15, 2017, 10:52:10 PM6/15/17
to AdWords API Forum
Hi Sergiu,

Could you confirm if you are using the installed app flow? If yes, please refer to the guide in the link provided. If the issue persists, please send a step by step screenshot replicating your issue so I can better investigate. Please reply using Reply privately to author when sending the requested information.

Sergiu Obreja

unread,
Jun 20, 2017, 4:38:10 AM6/20/17
to AdWords API Forum
Hello!

I'm using web application flow.
I've managed to make it work. After the log in into the consent screen I'm redirected back to my page and I get a refresh token which I store in my database. Anytime I want to connect again on the behalf of that specific user I'm adding the refresh token to the OAuth2 object.

Peter Oliquino

unread,
Jun 20, 2017, 4:56:40 AM6/20/17
to AdWords API Forum
Hi Sergiu,

Glad to hear that you are now able to continue. Feel free to let us know should you encounter any issues with the AdWords API.
Reply all
Reply to author
Forward
0 new messages