Using postman and use refresh token to get access token. After 7 days, invalid_grant, bad request.

1,256 views
Skip to first unread message

Minyen Hsieh

unread,
Nov 7, 2022, 12:26:19 PM11/7/22
to Google Ads API and AdWords API Forum
Problem: I'm using the refresh token (I got it from the Oauth2.0 playground) to get the access token using the POST method in POSTMAN. It worked, however, after 7 days, it gives me an {'error': 'invalid_grant', 'error_description': 'Bad Request'}

I am trying to troubleshoot but I have so many questions:

First of all, my overall purpose is to hit Google Ads API to extract data from our company's Google Ads Account (just for our own account, not managing any other clients' accounts) for reporting purposes. In the OAuth consent screen, I can only pick External for the USER TYPE, the INTERNAL option is greyed out. I am just doing reporting for our company's own reporting, do I need to try to make it internal? Is it necessary? How?

I need to use refresh token to get access token, it worked in the beginning but after 7 days, I got {'error': 'invalid_grant', 'error_description': 'Bad Request'} as mentioned above. Is it because my refresh token only lives for 7 days? Or is it due to other issue? How do I make it live forever? I thought changing my Google Project from Testing to Production would solve this issue, but it didn't.

It seems like the only Google Ads API scope provided is 'https://www.googleapis.com/auth/adwords', which is a sensitive scope. Does that means I will need to verify my app so that I can get a refresh token that never expires?

I am very confused and stumped. Your help will be so appreciated!

Google Ads API Forum Advisor

unread,
Nov 7, 2022, 8:38:54 PM11/7/22
to mhs...@spscommerce.com, adwor...@googlegroups.com
Hi Minyen,

Thank you for raising this concern to us. This is Carmela from the Google Ads API team.

With regard to your concern, I understand that you encountered the invalid_grant error. To answer your questions in general and give you information about the said error, it means the token has expired or revoked. Its common cause is when 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. You mentioned that you already tried changing your Google Project from "Testing" to "In Production" status. Having said that, I would suggest following these instructions as this is the way to prevent refresh tokens expiring in 7 days.

For more information about the refresh token expiration, you may then see this documentation. Also, you may refer here to this guide for the steps if you want to know how you can regenerate credentials and refresh tokens.

I hope this helps. Let us know if you have further questions.
 
Regards,
Google Logo
Carmela
Google Ads API Team
 


ref:_00D1U1174p._5004Q2g16R4:ref

Minyen Hsieh

unread,
Nov 8, 2022, 4:14:40 PM11/8/22
to Google Ads API and AdWords API Forum
Hi Carmela,

So you're saying once I complete the app verification process, then I can get a refresh token that never expires?

To complete the verification process, I will need to input Application Home Page and Application Privacy Policy, and also create a Youtube video for demo. I am only using this app just to get marketing data for internal reporting, so I don't have an application home page, nor do I have an application privacy policy. What can I do in this situation?

Thanks,
Minyen

Google Ads API Forum Advisor

unread,
Nov 9, 2022, 1:46:57 AM11/9/22
to mhs...@spscommerce.com, adwor...@googlegroups.com

Hi Minyen,
 

I'm Darwin, also a member of the Google Ads API team. I work with Carmela and allow me to assist you here. I hope you are doing well today.
 

Please see my answer to your question below.

 

1.) So you're saying once I complete the app verification process, then I can get a refresh token that never expires?
 

  • Yes, you can prevent the refresh token expiring in 7 days. For more information about the refresh token expiration, you may then see this documentation. Also, you may refer here to this guide for the steps if you want to know how you can regenerate credentials and refresh tokens.


2.) To complete the verification process, I will need to input the Application Home Page and Application Privacy Policy, and also create a Youtube video for the demo. I am only using this app just to get marketing data for internal reporting, so I don't have an application home page, nor do I have an application privacy policy. What can I do in this situation?
 

  • For this, before our team provided a specific recommendation to this situation, could you please provide a full screenshot of the apps you are using to get the data reporting ?


Regards,

Google Logo
Darwin
Google Ads API Team
 

 

 



ref:_00D1U1174p._5004Q2g16R4:ref

Minyen Hsieh

unread,
Nov 9, 2022, 1:57:57 PM11/9/22
to Google Ads API and AdWords API Forum
Hi Darwin,

We are not really creating a specific app, we are basically just using POSTMAN and INFORMATICA CLOUD to automate getting data and loading into our Snowflake database. Does that answer your question?

Minyen

Google Ads API Forum Advisor

unread,
Nov 9, 2022, 10:12:14 PM11/9/22
to mhs...@spscommerce.com, adwor...@googlegroups.com
Hi Minyen,

Thank you for getting back to our team.

Moving forward, kindly note that the reason why we are suggesting you to follow these instructions is because as per this documentation, in order to avoid the invalid_grant error which you had encountered. For further guidance, I would suggest reaching out to the Google Cloud Support team via this link.

Regards,
Google Logo
Carmela
Google Ads API Team
 


ref:_00D1U1174p._5004Q2g16R4:ref
Reply all
Reply to author
Forward
0 new messages