Search code examples
google-chrome-extensionoauth-2.0access-tokengmail-api

How can i refresh authentication token generated using chrome.identity namespace?


I am creating a chrome extension for gmail. I have generated an access_token to call gmail api. But seems like access token has an expiration time. Will my extension work if the token has expired? If it doesn't, then how can i handle this?


Solution

  • The calls to the API with an expired token will return an error (code 401). In that case, you have to renew the authorization token using chrome.identity.getAuthToken, and try the request again with the new token.