Making first request problem - can not get refresh token

612 views
Skip to first unread message

Yuriy P.

unread,
Jan 19, 2016, 2:17:41 PM1/19/16
to AdWords API Forum
Dear all,

I'm trying to run some examples from adwords api (v201509) client lib on my web server, but I'm not able to get refresh_token.
I've checked that my server does support SOAP, cURL and openSSL  on php 5.6+

Here are the steps I took:
  • I have created adwords manager account to get developers token and added my existing adwords account to it.
  • Then I realised I need a test account, so I've created another adwords manager account (test) and created child adwords account (test) . However I don't have an option to see developers token in this test account. As it says on the "get started" page, I can use developers token from the account I've created in the first step (non-test account) . But I don't really understand how these two accounts are connected? My live and test adwords account managers has different login details.
  • Then I have logged into google developers console with the same details I use to log in to adwords manager, created a new project and generated new client_id and client_secret for web access
When I try to run this file on my server: googleads-php-lib-master/examples/AdWords/Auth/GetRefreshToken.php

I get the following response:

Log in to your AdWords account and open the following URL: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=239133760842-k074cjmhr15hfn347ugald8j9ekp4bip.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fadwords&access_type=offline After approving the token enter the authorization code here: Your OAuth2 Credentials are incorrect. Please see the GetRefreshToken.php example. { "error" : "invalid_request", "error_description" : "Missing required parameter: code" }

If I go to that URL, I see an error: 

400. That’s an error.

Error: redirect_uri_mismatch

Application: [my-app]

You can email the developer of this application at: [my-email]

The redirect URI in the request: urn:ietf:wg:oauth:2.0:oob can only be used by a Client ID for native application. It is not allowed for the 'WEB' client type. You can create a Client ID for native application in the Credentials section of the Google Developers Console.

However my credentials were generated for the web access

Any help would be appreciated 

Anthony Madrigal

unread,
Jan 19, 2016, 5:06:40 PM1/19/16
to AdWords API Forum
Hello Yurly,

I recommend following this guide on setting up OAuth with PHP. If you are still running to issues, please reply privately to author your client customer Id.

Regards,
Anthony
AdWords API Team

Yuriy

unread,
Jan 20, 2016, 9:05:22 AM1/20/16
to AdWords API Forum
Hi,

Not sure with what details do I have to login to Google cloud console - with the one where I have my test Google Adwords manager OR with details from my live adwords manager where I have my developer token generated? 

Anthony Madrigal

unread,
Jan 20, 2016, 10:30:25 AM1/20/16
to AdWords API Forum
Hi,

When generating a new refresh token, you will need to use the account in which you want to generate the token for in the cloud console.

Cheers,
Anthony
AdWords API Team
Reply all
Reply to author
Forward
0 new messages