google-auth-library-python icon indicating copy to clipboard operation
google-auth-library-python copied to clipboard

Implement pre-emptive credential refresh

Open igorbernstein2 opened this issue 3 years ago • 1 comments

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Is your feature request related to a problem? Please describe. In the current implementation OAuth credentials get refreshed inline when auth headers are requested by gRPC. This causes latency spikes that are hard to debug.

Describe the solution you'd like Implement a stale state for OAuth tokens where the existing token is returned, and a refresh is triggered in the background. Prior art: https://github.com/googleapis/google-auth-library-java/pull/646

Describe alternatives you've considered Other possibilities are:

  • Have an always running background thread to always refresh the token. This will have lifetime issues since credentials dont currently have a way to close them/stop the thread

igorbernstein2 avatar Oct 11 '22 18:10 igorbernstein2

Implemented for sync credentials in https://github.com/googleapis/google-auth-library-python/pull/1368.

Async implementation is blocked until the API / Inheritance issues are sorted.

clundin25 avatar Apr 19 '24 20:04 clundin25