Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reuse access token to avoid some unnecessary round trips to google site #29

Open
c0b opened this issue Apr 24, 2016 · 2 comments
Open

Comments

@c0b
Copy link

c0b commented Apr 24, 2016

I have played with this library a few days it's working nicely while I noticed when my application need to talk to google for longer tasks, some part of this code is not caching and retrieving some resource again and again, for example google's oauth token has one hour validity by default, so within the hour we can reuse it, only need to refresh it until it's almost expiring,
I'm doing some code changes locally to cache and it works better, can make a PR if it's welcome.

btw, google's library says refreshAccessToken is deprecated [2], I have switched to use getRequestMetadata; that is less code because google-auth-library handles token expiry and refresh itself pretty well

  1. https://github.com/ShinyAds/node-google-dfp/blob/master/lib/DfpUser.js#L120
  2. https://github.com/google/google-auth-library-nodejs/blob/master/lib/auth/oauth2client.js#L189-L195
@mvhirsch
Copy link
Contributor

@c0b I just ran into the same problem. Could you please make a PR, so this could be merged into the library, too?

@mvhirsch
Copy link
Contributor

Sadly the method getRequestMetadata isn't officially documented (heck, it's already the "preferred way" to authorize, because .authorize is already deprecated).
For curious ones I'll just leave this here: googleapis/google-auth-library-nodejs#138

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants