With Google Identity Services (GIS) JavaScript SDK, how do you extend a session?

Viewed 52
1 Answers

As mentioned in the Answer

To refresh the access token in a transparent way for the end-user you have to use the Refresh Token, This token will also come in the response to your call.

With this token, you can do a POST call to the URL: https://www.googleapis.com/oauth2/v4/token with the following request body

client_id: <YOUR_CLIENT_ID>
client_secret: <YOUR_CLIENT_SECRET>
refresh_token: <REFRESH_TOKEN_FOR_THE_USER>
grant_type: refresh_token

refresh token never expires so you can use it any number of times. The response will be a JSON like this:

{
  "access_token": "your refreshed access token",
  "expires_in": 3599,
  "scope": "Set of scope which you have given",
  "token_type": "Bearer"
}

You can also refer to the Github issue and Answer where a suggested approach is to use a listener and reloadAuth.

For more information, you can refer to the documentation ,Answer and doc.

Related