Skip to content

Commit

Permalink
chore(auth): fixup some docs (googleapis#11023)
Browse files Browse the repository at this point in the history
- Added a missing godoc link
- Simplified NewCachedTokenProvider to not explain what the CachedTokenProviderOptions already do.
- removed the word stale from doc as that refers to internal state of a token that is not otherwise expressed in documentation.

Internal Bugs: 372880552, 372881290, 372879789
  • Loading branch information
codyoss authored Oct 25, 2024
1 parent 1eb48b7 commit e5bec20
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ func NewCredentials(opts *CredentialsOptions) *Credentials {
return creds
}

// CachedTokenProviderOptions provided options for configuring a
// CachedTokenProvider.
// CachedTokenProviderOptions provides options for configuring a cached
// [TokenProvider].
type CachedTokenProviderOptions struct {
// DisableAutoRefresh makes the TokenProvider always return the same token,
// even if it is expired. The default is false. Optional.
Expand All @@ -253,7 +253,7 @@ type CachedTokenProviderOptions struct {
// seconds. Optional.
ExpireEarly time.Duration
// DisableAsyncRefresh configures a synchronous workflow that refreshes
// stale tokens while blocking. The default is false. Optional.
// tokens in a blocking manner. The default is false. Optional.
DisableAsyncRefresh bool
}

Expand All @@ -280,12 +280,7 @@ func (ctpo *CachedTokenProviderOptions) blockingRefresh() bool {

// NewCachedTokenProvider wraps a [TokenProvider] to cache the tokens returned
// by the underlying provider. By default it will refresh tokens asynchronously
// (non-blocking mode) within a window that starts 3 minutes and 45 seconds
// before they expire. The asynchronous (non-blocking) refresh can be changed to
// a synchronous (blocking) refresh using the
// CachedTokenProviderOptions.DisableAsyncRefresh option. The time-before-expiry
// duration can be configured using the CachedTokenProviderOptions.ExpireEarly
// option.
// a few minutes before they expire.
func NewCachedTokenProvider(tp TokenProvider, opts *CachedTokenProviderOptions) TokenProvider {
if ctp, ok := tp.(*cachedTokenProvider); ok {
return ctp
Expand Down

0 comments on commit e5bec20

Please sign in to comment.