Refresh token expiration time

189 views
Skip to first unread message

Cristian Andrei Grigore

unread,
Mar 14, 2024, 8:37:37 AM3/14/24
to Google Ads API and AdWords API Forum
My use-case is a no GUI script that fetches data from the Google Ads API.

I understand that one of the steps is to Fetch a refresh token.

What is the expiration time for the refresh token in production? How many times do I need to follow the steps from Fetch a refresh token?

Google Ads API Forum Advisor

unread,
Mar 14, 2024, 11:59:05 AM3/14/24
to cristianan...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for contacting the Google Ads API support team.

By reviewing your concern, I understand that you would like to know the expiration time for a refresh token in production. I would like to inform you that the refresh token expires every 7 days when your Google project's publishing status is Testing. Kindly refer to the document Refresh token expiration to get more information.

Please note that if you want to avoid the refresh token expiring in 7 days, go to the Google API Console and navigate to the OAuth consent screen and then change the publishing status to “In production”. If its publishing status is in "In production" already, this means that you have already applied this Setting up your OAuth consent screen instruction to that account that makes the life of the refresh token longer.

Also, kindly note that once the refresh token is expired, you need to generate a new refresh token by following the steps providedd in the document Fetch a refresh token.
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02rzwu0:ref" (ADR-00227275)

Thanks,
 
Google Logo Google Ads API Team


 

Cristian Andrei Grigore

unread,
Mar 14, 2024, 6:24:12 PM3/14/24
to Google Ads API and AdWords API Forum
Hello, 

Thank you for the answer.
Does that mean that I will always have to do this step?
      2. The oauth2l command opens a Google Account login window in a new browser window and takes you through the OAuth 2.0 authentication steps.
 If yes, is there another way to implement this using .Net?

Google Ads API Forum Advisor

unread,
Mar 15, 2024, 4:57:09 AM3/15/24
to cristianan...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for getting back to us.

Kindly note that if you navigate to the OAuth consent screen in the Google API Console and switch the publishing status to "In production", the refresh token will not expire. I would recommend you to kindly refer to the .Net sample code in generating the refresh token using the Google Ads API. Also, I would suggest you to refer to the Generate tokens guide as it describes how to generate the refresh token using the OAuth2 Playground

Cristian Andrei Grigore

unread,
Mar 15, 2024, 6:18:43 AM3/15/24
to Google Ads API and AdWords API Forum
Hello,

Thank you for your answer.

However, I don't want to set the User Type to External. I want to use Internal. So I have:
1. OAuth consent screen - User Type - Internal
2. Credentials - OAuth 2.0 Client IDs - Type Desktop

According to this Offline access, I understand that "For the desktop app type, offline access is enabled by default—you don't have to explicitly request it.".

Does that mean the refresh token will not expire once I get one?

Cristian Andrei Grigore

unread,
Mar 21, 2024, 7:01:30 PM3/21/24
to Google Ads API and AdWords API Forum
I'm still waiting for a response.

Google Ads API Forum Advisor

unread,
Mar 22, 2024, 5:21:22 AM3/22/24
to cristianan...@gmail.com, adwor...@googlegroups.com
Hi,

According to the Oauth documentation, the expiration of refresh tokens depends on various factors, including the configuration of your OAuth consent screen and the usage patterns. In general:

1. For OAuth consent screens configured for external user types with a publishing status of "Testing":

  • If your application requests limited OAuth scopes (such as name, email address, and user profile), the refresh token may expire after 6 months if not used.   
2. For regular user accounts:
  • Refresh tokens do not have a predefined expiration, but they are subject to certain limits. For example, there is a limit of 100 refresh tokens per OAuth 2.0 client ID.
  • If this limit is reached, generating a new refresh token automatically invalidates the oldest refresh token without warning.
If you still need any further information on refresh tokens and expiration,  I would recommend you to reach out to the GCP Product support team.
Reply all
Reply to author
Forward
0 new messages