Skip to content

docs: How to refresh/revoke a token #262

Description

@ryanseys

As suggested by #261, we should document how to refresh the token and revoke a token in the README.

Activity

  1. tnguyen14 commented on Nov 1, 2016

    @tnguyen14

    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?

  2. jmdobry commented on Dec 28, 2016

    @jmdobry
    Contributor

    Making authenticated requests: https://github.com/google/google-api-nodejs-client#making-authenticated-requests

    If you provide a refresh_token and expiry_date (milliseconds since the Unix Epoch) and the access_token has expired, the access_token will be automatically refreshed and the request is replayed

    Manually refreshing an access token: https://github.com/google/google-api-nodejs-client#manually-refreshing-access-token

  3. tnguyen14 commented on Jan 3, 2017

    @tnguyen14

    @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?

  4. jmdobry commented on Jan 3, 2017

    @jmdobry
    Contributor

    expiry_date defines when the token expires.

    If you provide a refresh_token and expiry_date the library will automatically refresh the access token if it is expired.

  5. tnguyen14 commented on Jan 4, 2017

    @tnguyen14

    is there any limit to the expiry_date? Can it be 30 days? a year?

  6. jmdobry commented on Jan 29, 2017

    @jmdobry
    Contributor

    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.

  7. tnguyen14 commented on Feb 7, 2017

    @tnguyen14

    @jmdobry I tried adding the expiry_date property in the credentials object 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?

  8. Lewenhaupt commented on Mar 21, 2017

    @Lewenhaupt

    @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.

  9. tnguyen14 commented on Mar 21, 2017

    @tnguyen14

    @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.

  10. coderaven commented on Sep 11, 2017

    @coderaven

    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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

🚨This issue needs some love.triage meI really want to be triaged.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions