Ошибка поулчения access token

1,830 views
Skip to first unread message

treto...@gmail.com

unread,
Oct 26, 2016, 10:40:53 AM10/26/16
to AdWords API Forum
Добрый день! Получаю ошибку при получении access token из refresh token:
{
 "error": "invalid_grant",
 "error_description": "Bad Request",
 "error_uri": ""
}
Код ошибки - 400 

Отправляю запрос: 
https://www.googleapis.com/oauth2/v3/token&grant_type=refresh_token&client_id=ххххххххх&client_secret=хххххххххх&refresh_token=ххххххххххххххх

Раньше работало все замечательно, пару недель назад перестало.
Причет ошибка только на тестовом аккаунте.
На рабочым аккаунте все работает.
Подскажите в чем может быть причина ошибки?
Может refresh_token устарел? 
Может нужно перегенерировать refresh_token?

Shwetha Vastrad (AdWords API Team)

unread,
Oct 26, 2016, 12:41:34 PM10/26/16
to AdWords API Forum
Hi,

This error normally happens if you missed something in the configuration of OAuth2 credentials or refresh token. Could you please confirm if you followed this guide to generate your credentials and which app type have you configured? Also, please make sure that when generating the refresh token for a test account, you're logged in as a user of the test account and not the production account. 

Regards,
Shwetha, AdWords API Team.

Kio Mat

unread,
Oct 26, 2016, 1:00:03 PM10/26/16
to AdWords API Forum
Все работало еще пару недель назад. Все настроено. Просто в один момент перестало работать.

среда, 26 октября 2016 г., 19:41:34 UTC+3 пользователь Shwetha Vastrad (AdWords API Team) написал:

Shwetha Vastrad (AdWords API Team)

unread,
Oct 26, 2016, 4:17:11 PM10/26/16
to AdWords API Forum
Hi,

I'm afraid I can only respond in English. Refresh tokens can sometimes become invalid as well. There is a maximum of 50 refresh tokens that can be valid at a time. If you generate a refresh token for the 51st time, the 1st refresh token becomes invalid. Refresh tokens can also be manually revoked. I would suggest that you generate a new refresh token and use this to get an access token by following the instructions provided here

Let me know if this works.

treto...@gmail.com

unread,
Oct 27, 2016, 3:39:20 AM10/27/16
to AdWords API Forum
Получаю новый refresh token.
Использую  Offline access.
Для начала отправляю запрос вида:
https://accounts.google.com/o/oauth2/v2/auth?%20scope=email%20profile&%20state=security_token%3D138r5719ru3e1%26url%3Dhttps://oa2cb.example.com/myHome&%20redirect_uri=https%3A%2F%2Foauth2.example.com%2Fcode&%20response_type=code&%20client_id=ххххххххххххх&%20access_type=offline

Должен в ответ code прийти, но получаю :
400. That’s an error.
Error: invalid_request 

treto...@gmail.com

unread,
Oct 27, 2016, 5:57:32 AM10/27/16
to AdWords API Forum
Тут разобрался, посылал запрос:

https://accounts.google.com/o/oauth2/v2/auth?scope=email%20profile&state=security_token%3D138r5719ru3e1%26url%3Dhttps://oa2cb.example.com/myHome&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&client_id=хххххххх&access_type=offline

В отчет получил code. 
Далее использую code в запросе:

https://www.googleapis.com/oauth2/v4/token?code=ххххххх&client_id=ххххххх&client_secret=ххххххх&redirect_uri=https://oauth2.example.com/code&grant_type=authorization_code

В ответ получаю:
{
 "error": "redirect_uri_mismatch",
 "error_description": "Bad Request",
 "error_uri": ""
}

в ответ получаю 

treto...@gmail.com

unread,
Oct 27, 2016, 6:41:49 AM10/27/16
to AdWords API Forum
Разобрался с проблемой, не одинаковые redirect_uri была, сделал в первом и втором запросе одинаковые redirect_uri и все сработало. Спасибо. Проблема решена.
Reply all
Reply to author
Forward
0 new messages