chrome.identity.getAuthToken and refresh token?

2.2k views Asked by At

I was under the impression that when using chrome.identity.getAuthToken and gapi.auth.authorize({immediate: true...}); the token would be refreshed in the background.

But it clearly does not... after 40-50 minutes the GMail token expires, the cached one is used but returns 401, as one can expect.

Can a refresh token be received (I know it only comes the first time the access token is received) by using chrome.identity.getAuthToken? It seems to only return the token string in the callback.

Next to the above question, can I retrieve the experation time to check when to re-generate the access token?

This whole Oauth 2 is still harder than I expected it to be.

1

There are 1 answers

3
Ikirys On

Pretty sure the expected response to the 401 is to revoke the auth token, then request another one.

https://developer.chrome.com/apps/identity#method-removeCachedAuthToken

chrome.identity.removeCachedAuthToken({token: }, function callback)