-
Notifications
You must be signed in to change notification settings - Fork 11
Description
Hi,
Is your feature request related to a problem?.
Yes, we are using the library to make http calls to a GCP Cloud Run service with the IdTokenClient. But sometimes, we have a 401 because the token is expired.
After investigation, those 401 occure when the token is about to expire. The root cause is a clock delay on the system calling system.
Describe the solution you'd like
We want to be hable to pass a parameter, like eagerRefreshThresholdMillis in OAuth2Client , to force refresh token x millisecond before the end.
Describe alternatives you've considered
To mitigate the issue, we have overrided the getRequestMetadataAsync in IdTokenClient to take into account a custom eagerRefreshThresholdMillis at this line .
Additional context
We create the client with googleAuth.getIdTokenClient(targetAudience) and get the token (auth headers) with getRequestHeaders