Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Requirements for long lived refresh token

We are using Azure Data Factory to load GA4 data and Ads API data to data warehouse. To make the connection we have a Google Cloud project and use its credentials to authenticate.

I have setup ADF so that it will use a refresh token to get a new access token. The problem that im having is that refresh token expires in 7 days.

My understanding is that to expand the refresh token I need to publish the cloud project. I have done this in https://console.cloud.google.com/apis/credentials/consent . Under "Publishing status", I have clicked the "Publish app" button. Its currently showing "In production" and has a button labelled "Back to testing".

Sadly the refresh token still expires in 7 days. What am i missing or doing wrong? Is there some other place to publish the app? 

At the moment i'm using developer playground to generate the refresh token. https://developers.google.com/oauthplayground/

Access token is generated trough https://www.googleapis.com/oauth2/v4/token API call.

1 3 4,912
3 REPLIES 3

Hi @Mefistofeles,

Welcome to the Google Cloud Community!

You are correct that once the Publishing status is in "In Production", tokens shouldn't expire after 7 days. Can you try doing the steps below from this Stack Overflow thread[1]:

  1. Go to https://console.cloud.google.com/apis/credentials/consent and change from the testing status to published.
  2. Delete the current token file.
  3. Authorize the API again by signing into your gmail account. You will be sent to a warning screen. From there, you can choose to proceed.
  4. When done you'll get a new token file

If the above option doesn't work, you can contact Google Cloud Support to further look into your case. Thank you! 😃

[1]. https://stackoverflow.com/questions/66058279/token-has-been-expired-or-revoked-google-oauth2-refresh...

Hello, I also encountered this problem, very distressed, after Posting the status, refresh token really does not expire after seven days?

Hi @Mefistofeles  here are some points to consider that might help you resolve this issue:

Steps to Resolve the Refresh Token Issue

  1. Verify Google Cloud Project Configuration:

    • Ensure your Google Cloud project is properly configured and that all requested permissions (scopes) are approved and justified in the OAuth consent screen.
  2. Use a Production Environment:

    • It's crucial to generate the refresh token in a real production environment rather than using testing tools like the OAuth 2.0 Playground, which sometimes generate tokens with shorter expiration periods.
  3. Check OAuth Client Type:

    • Verify that your OAuth client type is correctly configured as a "Server Application" instead of a "User Application". This can affect the duration of the refresh token.
  4. Documentation and Code Example:

    • Make sure to follow the guides and examples from the official Google documentation. Here is a useful link for managing access tokens: Managing Access Tokens

Alternative Solution

If you are looking for an easier way to handle authentication and data transfer, you might consider using services that simplify this process. For instance, platforms like windsor.ai offer specific connectors for GA4 and facilitate data transfer to destinations like AzureSQL, automatically managing authentication and token renewal.

Using such solutions can help you avoid the challenges you are currently facing and ensure that data is transferred continuously and without interruptions, saving you time and effort in managing tokens and manual authentications.

Hope this helps!

Top Labels in this Space
Top Solution Authors