Auth0 Home Blog Docs

Google access_token expires and does not refresh

google
oauth2
#1

Hi all,
I am facing an issue regarding Google Login.

I am actually authenticating users using email/password, but I have to add Google Calendar integration so I added a Google Social Connection with the corresponding client_id and client_secret. So far so good.

I am being able to request user’s profile to get the google access_token (https://zen-dev.auth0.com/api/v2/users/{auth0_user_id}) and I am getting a valid response like this:

{
    "email": "my_email@example.com",
    "user_id": "{auth0_user_id}",
    "identities": [
        {
            "provider": "google-oauth2",
            "access_token": "{google_ access_token}",
            // Note that I am not getting a refresh_token
            "expires_in": 3600,
            "user_id": "xxxxxxxx",
            "connection": "google-oauth2",
            "isSocial": true
        }
    ]
}

The problem comes when google_access_token expires, it seems once the token has expired, it is not refreshed any more. So I can’t access Google Calendar API any more neither.
At this point, I am at the backend side, so I can’t ask the user to re-login.

What can I do regarding that? How can I handle this situation?

Thanks.