Auth0 Home Blog Docs

Use Google refresh_token to obtain new Google access_token

How do we receive a new Google access_token given that we have a Google IDP refresh_token? All the docs I can find (after searching two work days) involve obtaining the refresh_token for Google, which has been solved by Can't get google refresh token using auth0.js

Our current attempts are feeble and involve POSTing the refresh token alongside from our backend directly to https://www.googleapis.com/oauth2/v4/token, which is responding with a 401 and the error message

The OAuth client was not found

Here’s what the full call looks like (I understand this is not an auth0 api call and might belong instead in a google forum. If that is the case, help me undestand where the auth0 -> Google handoff is, because currently we’re able to use the access_token from auth0’s Google IDP successfully, just not refresh it.

Here’s the API call:

    response = requests.post(
    url='https://www.googleapis.com/oauth2/v4/token',
    data={
        'client_id': AUTH0_CLIENT_ID,
        'client_secret': AUTH0_CLIENT_SECRET,
        'refresh_token': session['google-oauth2-refresh-token'],
        'grant_type': 'refresh_token',
    },
    headers={
        'Content-Type': 'aplication/x-www-form-urlencoded',
    },
)

Proposed Solution
Perhaps this is because the client_id and client_secret used with auth0 are not the same as the ones used by Google? If that’s the case, is it as simple as POSTing to google with specific google client_id and client_secrets which are different than the auth0 ones?

If this is not the proper location for this, please direct me elsewhere. Thank you!

Hey there!

Sorry for such huge delay in response! We’re doing our best in providing you with best developer support experience out there, but sometimes our bandwidth is not enough comparing to the number of incoming questions.

Wanted to reach out to know if you still require further assistance?