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

Misleading Documentation About Access Token Refresh Behavior #3604

Closed
utkarshchowdhary opened this issue Jan 23, 2025 · 1 comment
Closed

Comments

@utkarshchowdhary
Copy link

The google-api-nodejs-client documentation states that the library will “automatically use a refresh token to obtain a new access token if it is about to expire” (Source). However, this statement is misleading because the library does not proactively refresh the token based on the remaining time before expiry. Instead, the token is refreshed only after it has expired, and certain criteria are met, as explained in the code comments here.

The criteria for refreshing the token include:

  1. The absence of expiry_date or the forceRefreshOnFailure flag is set.
  2. A failure response (401 or 403) from an API call due to an expired token.
  3. The presence of a refresh_token and/or a refreshHandler callback.

The phrase “about to expire” is inaccurate since the library does not evaluate the remaining time on the expiry_date. Instead, the token is used until it causes a failure, at which point a refresh is triggered. This can lead to confusion for developers expecting proactive token refreshing.

@utkarshchowdhary
Copy link
Author

My bad! I was setting expiry_date based off the current date instead of the issued_at date. All good now!

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

1 participant