Cannot access adwords API. Getting "error" : "invalid_grant".

605 views
Skip to first unread message

Jonathan Martins

unread,
Jan 6, 2014, 1:02:00 PM1/6/14
to adwor...@googlegroups.com
I used my MCC account to generate my WEB Application. So now i have access to the client_id and the client_secret:

client_secret = "xxxxxxxxxxxxxxxxxxxxx"

I'm using the PHP client library and the GetRefreshToken.php dont give me a refresh token immediately it show me this:


After a click on this link I get a page with:

This app would like to:
Manage your AdWords campaigns
Accept

After click on Accept the pages reload and than i'm able to take a code (refresh_token?).


I put that token in auth.ini, but i'm still getting "invalid_grant" message...

Otherwise thinking that this code is not the refresh_token, i'm edit the GetRefreshToken.php and replace the $code var by the code above on line 65. Its not working too... Now i'm getting a error_description that said "Invalid Code".

-----------
In this post Jur has a similar problem:

But in my case I cant see the message after click accept: "Please copy this code, switch to your application and paste it there:" Is simple redirect to my Redirect_URI with the code parameter.
-------------

Thats for HELP, i'm stuck...

Josh Radcliff (AdWords API Team)

unread,
Jan 9, 2014, 11:52:42 AM1/9/14
to adwor...@googlegroups.com
Hi,

The issue here is that your application in Cloud Console is a Web application so during the flow there's an attempt to redirect to the URL you entered when you set up the application.

Per the PHP OAuth2 Wiki article, if you are using the GetRefreshToken.php example you will need to create a Native Application.  This will still allow you to request offline access but will send the redirect to your local host.

Please give that a try and let me know if that resolves the issue for you.

Thanks,
Josh, AdWords API Team
Reply all
Reply to author
Forward
0 new messages