Skip to content

Add eagerRefreshThresholdMillis parameter to the IdTokenClient to prevent getting invalid token on getRequestHeaders #531

@dstacko

Description

@dstacko

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    next major: breaking changethis is a change that we should wait to bundle into the next major versionpriority: p3Desirable enhancement or fix. May not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions