-
Notifications
You must be signed in to change notification settings - Fork 314
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
Token refresh on each API request when using UserAccessTokenCredentials #1341
Comments
I think
|
UserAccessTokenCredential was initially added for mTLS feature since at that time user credentials had issues (which is already fixed now). Therefore we want to deprecate UserAccessTokenCredential since it's google-auth specific, and not available in other languages. Users are recommended to use user credentials instead (google.oauth2.credentials.Credentials), which is a generic application default credential type available in all languages. To use it, simply run gcloud auth application-default login and let the client libraries automatically use it. |
I observed that requests to Google Cloud APIs take much longer when using
UserAccessTokenCredentials
(documented here) ascredentials
for client libraries, e.g., Storage library for Python.Diving into the code, I realized that
UserAccessTokenCredentials
triggers token refresh (resulting in an additional API request) on each request due to how thebefore_request
method is implemented:In comparison, the
before_request
method in the base class has a mechanism to trigger token refresh only when necessary:Would it be reasonable to check token validity before request in the
UserAccessTokenCredentials
strategy?The text was updated successfully, but these errors were encountered: