Repository navigation
docs: How to refresh/revoke a token #262
Description
Activity
Is there any update on this? I am seeing a token being expired (getting 401 response from the Drive api) pretty quickly (perhaps within a couple of hours). Is there any way to automatically refresh it?
Making authenticated requests: https://github.com/google/google-api-nodejs-client#making-authenticated-requests
If you provide a
refresh_tokenandexpiry_date(milliseconds since the Unix Epoch) and theaccess_tokenhas expired, theaccess_tokenwill be automatically refreshed and the request is replayedManually refreshing an access token: https://github.com/google/google-api-nodejs-client#manually-refreshing-access-token
@jmdobry what is the logic behind
expiry_date? does it request with Google how long the token should be valid for? If so, is it my responsibility to refresh it manually before that date ends, or does the library automatically refresh it in the background somehow, at some time?expiry_datedefines when the token expires.If you provide a
refresh_tokenandexpiry_datethe library will automatically refresh the access token if it is expired.is there any limit to the
expiry_date? Can it be 30 days? a year?- added a commit that references this issue
on Jan 20, 2017 I am not aware of any limit, nor could I find any evidence of one. However, you should probably code your app to assume tokens are rather short-lived.
@jmdobry I tried adding the
expiry_dateproperty in thecredentialsobject for each API call for 15 days out (new Date()).getTime() + (1000 * 60 * 60 * 24 * 15). However, it seems like the auth token is still expired way before that (within the same day maybe). Is there a way I could debug this?
When will the token be refreshed automatically by the library?@ryanseys if I provide the expiry_date and the access_token is expired, how do I receive the updated accessToken? Because I'm guessing I would like to store that one istead of the old expired one in my db?
@tnguyen14 I believe I have read in the docs that the token expires in one hour.
@Lewenhaupt thanks. if you have a reference to that doc, I'd love to take a look. It would also be good to know if there's any good way to renew this token in the background if possible.
Hi, is there an update to this? I am having the same issue as @Lewenhaupt and had also think of the solution to store the updated access token instead of the expired one in the db - is there any way I can do this?
- addedtriage meI really want to be triaged.I really want to be triaged.🚨This issue needs some love.This issue needs some love.
on Apr 6, 2020
As suggested by #261, we should document how to refresh the token and revoke a token in the README.