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

TokenRefresher error handling #303

Open
phillebaba opened this issue Sep 1, 2021 · 1 comment
Open

TokenRefresher error handling #303

phillebaba opened this issue Sep 1, 2021 · 1 comment

Comments

@phillebaba
Copy link

Which version of the SDK was used?

v0.14.0

Which platform are you using? (ex: Windows, Linux, Debian)

Linux

What problem was encountered?

Currently the TokenRefresher function passed when creating a NewToken does not have a clear method of dealing with errors when a token refresh fails.

func NewTokenCredential(initialToken string, tokenRefresher TokenRefresher) TokenCredential {

Some documentation recommends returning a 0 to stop the token refresh all together, but this is not really an optimal solution. I have seen scenarios where Azure API rate limits have been reached where it would be better to just retry later in an attempt to wait it out. Either way I feel like there should be a better solution to the token refresh logic.

The point of creating this issue is to start a discussion about a better solution, or understand why the way it is done today is the most optimal solution.

How can we reproduce the problem in the simplest way?

N/A

Have you found a mitigation/solution?

N/A

@MaurGi
Copy link
Member

MaurGi commented Dec 14, 2021

I agree with this - returning 0 is not a good option, eventually the token will expire and no one will evel refresh it again - so retrying is a good idea - but it should be retrying only for a limited time, then panic/bail because it cannot be refreshed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants