문제

I've been crawling the internet all morning trying to figure this out. I'm trying to get access to a Adwords test account through the API but I keep receiving "An error has occurred: { "error" : "invalid_grant" }". I've seen this is quite a common problem so perhaps if I outline what I've done step by step someone can correct me. Hopefully!

  1. Created a Google adwords account and set up a campaign.

  2. Created a MCC account. Added Google adwords account and applied for API access (pending). Noted API key, client id for auth.ini.

  3. Created a test MCC account and added Google adwords account. Noted client id for auth.ini.

  4. Using the Google account of both MCC accounts went into the API console and created a new installed application app. Noted all keys/tokens.

  5. Downloaded the PHP code examples and libs. Ran get GetRefreshToken.php, granted accesses to app(s) and noted refresh token for auth.ini

  6. Set up auth.ini populating developerToken, userAgent, clientCustomerId, client_id, client_secret and refresh_token.

  7. Now I've tried using BOTH sets of tokens and ids from the test MCC account API console and the live MCC account API console. Both give me the same error. I've tried regenerating all tokens several times.

  8. Gave up and came crawling to StackOverFlow.

Is the invalid_grant message related to Auth or my developerToken token not being activated yet (sure it said I could use my test account though) or because I haven't set up any of the billing?

도움이 되었습니까?

해결책 2

I had the same situation for a long time. But solution was very simple.

The code getting after authorizing the Google is not your refresh token.Its is only an access token(I guess.)

You have to add this code to GetAccessToken's $code variable function in getrefreshtoken.php file and it will return the actual Refresh token.

This solved my issue.

다른 팁

In my case the problem was at step 5 in your list; I had copied the authorization code from my browser after granting access, rather than the refresh token generated by GetRefreshToken.php after I pasted the authorization code there.

It is very important to note that the SDK is designed to be used through PHP-Cli. So please don't use it via browser. If you still run it by commenting out return line you'll get into further problems to comment that on each file :)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top