{'error': 'invalid_grant', 'error_description': 'Bad Request'}

33,074 views
Skip to first unread message

Diana Dziubak

unread,
Mar 23, 2020, 7:15:39 AM3/23/20
to AdWords API and Google Ads API Forum

Hi Adwords team!

 

I’m using developer_token to collect data from Google ads in my internal database, recently I got an error

 

{'error': 'invalid_grant', 'error_description': 'Bad Request'}

 

Please tell me the reason for the error and the solution, to continue the correct operation.

 

Have a nice day!

Google Ads API Forum Advisor Prod

unread,
Mar 23, 2020, 12:52:44 PM3/23/20
to petrovna...@gmail.com, adwor...@googlegroups.com
Hi Diana,

Thank you for reaching out. The "invalid_grant" error usually indicates that the access or refresh token being passed in your request is incorrect or invalid. Please make sure the email address used to generate the OAuth credentials has access to your account. If it does, please try generating a new set of OAuth credentials by following the guide here.

If you are still having an issue, please share the email address you are using to generate the credentials as well as your client customer ID.

Regards,
Mitchell
Google Ads API Team

ref:_00D1U1174p._5001UXWCTf:ref

Diana Dziubak

unread,
Mar 24, 2020, 3:38:08 AM3/24/20
to AdWords API and Google Ads API Forum
Hi!

Thanks for your answer. But I still have a problem with this.

 My email address - petrovna...@gmail.com

 My client customer ID - 864-831-5368

Google Ads API Forum Advisor Prod

unread,
Mar 24, 2020, 1:13:50 PM3/24/20
to petrovna...@gmail.com, adwor...@googlegroups.com
Hi Diana,

Can you please provide your complete detailed request and response logs of your API call via Reply privately to author so that I can further investigate the issue? You can find information on enabling logging in the ReadMe of your client library.

ReVo

unread,
Dec 19, 2023, 3:34:47 PM12/19/23
to Google Ads API and AdWords API Forum
Hi there,

What if the error  {"error": "invalid_grant", "error_description": "Bad Request"} appears when trying to exchange code for access and refresh tokens? I've already tried a bunch of possible solutions including generating a new client secret, but it didn't help. Here are the parameters that I pass. Thanks a lot. Screenshot 2023-12-19 223228.png

Best regards,
Jerry

Google Ads API Forum Advisor

unread,
Dec 19, 2023, 5:58:59 PM12/19/23
to adwor...@googlegroups.com
Hi,

Thank you for getting back to us.

After reviewing your concern, I understand that you are encountering the invalid_grant error while creating a campaign via the Google Ads API.

The common cause for this error is that, a Google Cloud Platform project with an OAuth consent screen configured for an external user type and a publishing status of "Testing" is issued a refresh token expiring in 7 days. So, in order to handle this error, go to the Google API Console and navigate to the OAuth consent screen. Then change the publishing status to "In production" to avoid the refresh token expiring in 7 days.

If you still encounter any issues, please provide us with the complete API logs (request and response with request-id and request header) generated at your end to better assist you.

If you are using a client library and haven't enabled the logging yet, I would request you to enable logging for the specific client library that you are using. You can refer to the guides Java, .Net, PHP, Python, Ruby or Perl to enable logging at your end. For REST interface requests, you can enable logging via the curl command by using the -i flag.
 
This message is in relation to case "ref:!00D1U01174p.!5001U0XWCTf:ref"

Thanks,
 
Google Logo Google Ads API Team

 

dimas ilham

unread,
Feb 22, 2024, 5:23:50 AM2/22/24
to Google Ads API and AdWords API Forum
Hi, i got same error, this might be cause my refresh token got expired, but when i want to reapply it, i got error like this:

Screenshot 2024-02-22 165248.png
is there any ways to solve it?

Google Ads API Forum Advisor

unread,
Feb 22, 2024, 9:14:23 AM2/22/24
to dimasi...@gmail.com, adwor...@googlegroups.com
Hi, 

Thank you for reaching out to the Google Ads API support team.

By reviewing your concern, I understand that your refresh token is getting expired and when you retry to apply for it you are getting an error message. I would recommend you to kindly refer to these steps and follow the guide on how to Generate tokens for more information. You may also refer to this document to Fetch a refresh token. Also, I would suggest you to kindly refer to the "Refresh token expiration" documentation as it describes the reasons for the refresh token expiration. 

If you have any further queries related to the Google Ads API, please open a new forum thread.
Reply all
Reply to author
Forward
0 new messages