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

Unhandled case: renewal fails because the token is too old #49

Open
pjt33 opened this issue Apr 11, 2019 · 0 comments
Open

Unhandled case: renewal fails because the token is too old #49

pjt33 opened this issue Apr 11, 2019 · 0 comments

Comments

@pjt33
Copy link

pjt33 commented Apr 11, 2019

I had an unhandled exception when calling PersistentAuthHelper.GetToken(string id, string resource) to log into an Azure subscription which I hadn't accessed in a very long time. Unfortunately I didn't document the details (or locate and back up the token cache) before trying a workaround, but the gist was that BaseAuthHelper.GetTokenInternal went into the case

if (cacheInfo.ExpiresOn <= DateTimeOffset.UtcNow)

which called

return await GetAuthorizationResultByRefreshToken(tokenCache, cacheInfo);

and that threw an exception on receiving an HTTP 400 response because the refresh token was too old.

A workaround is to change

if (ex.Message.IndexOf(" is expired") < 0)

to

                if (ex.Message.IndexOf(" is expired") < 0 && ex.Message.IndexOf(" has expired") < 0)

but I suspect that a better solution would be to rework the logic of GetTokenInternal so that it treats a cache entry older than some cutoff (90 days?) as non-existent.

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

1 participant