Skip to content
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

auth: CachedTokenProviderOptions.DisableAutoRefresh returns nil token and nil err #10414

Closed
quartzmo opened this issue Jun 21, 2024 · 0 comments · Fixed by #10415
Closed

auth: CachedTokenProviderOptions.DisableAutoRefresh returns nil token and nil err #10414

quartzmo opened this issue Jun 21, 2024 · 0 comments · Fixed by #10415
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@quartzmo
Copy link
Member

quartzmo commented Jun 21, 2024

The logic in cachedTokenProvider.Token does not check if the token is non-nil before returning it when cachedTokenProvider.autoRefresh is false.

Code

	tp := NewCachedTokenProvider(&countingTestProvider{count: 1}, &CachedTokenProviderOptions{
		DisableAutoRefresh: true,
	})
	freshToken, err := tp.Token(context.Background())
	if err != nil {
		fmt.Println(err)
	}
	if freshToken == nil {
		fmt.Println("freshToken is nil")
	}

Expected behavior

The CachedTokenProvider should fetch a new token the first time Token is called, even when DisableAutoRefresh is true.

Actual behavior

The CachedTokenProvider returns nil token and nil err the first time Token is called when DisableAutoRefresh is true.

@quartzmo quartzmo added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Jun 21, 2024
@quartzmo quartzmo self-assigned this Jun 21, 2024
quartzmo added a commit to quartzmo/google-cloud-go that referenced this issue Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
1 participant