[VS2017] Unable to login “failed to refresh access token”
I was running into this weird error today. For some reason (you know… it happens) Visual Studio lost it’s license. I was still logged in, but requested to re-enter my credentials. So I tried, but I kept getting errors. I then thought: let’s log out and log in again. So yeah, that didn’t happen…
The error I got was: “We could not refresh the credentials for the account. Failed to refresh access token.”. Refresh token refers to something that I know from OAuth authentication; being a token that you can use to get new authentication tokens after old ones expire. Ok so why was it not refreshing?
My Google search quest led me to a couple of answers. I’ll list them here for your convenience. One might work, the other might not based on the underlying issue your having. But chances are at least one of these solutions will work for you. I’ll start with the most important one; the one that fixed it for me….
- Delete %LOCALAPPDATA%\.IdentityService
Found here, simply delete the entire folder. There seems to be some identity related caching going on in there, deleting the folder will force the identity system to rebuild its cache and that seems to have fixed it.
- Delete everything under regkey: Computer\HKEY_CURRENT_USER\Software\Microsoft\VSCommon\ConnectedUser
Found here, this is a similar solution as there again is some logging info cached in that particular registry section.
- Delete AdalCache.cache in %USERPROFILE%\AppData\Local\Microsoft\VSCommon\VSAccountManagement
Found here. Yep, another cache you can delete.
- Add a second user account to Visual Studio
I didn’t actually try this, but if you have multiple accounts you could try adding another account, then removing the primary and re-adding it back in. Instructions on how to add a second account are found on this page.
Should you have found anything else that worked for you, feel free to drop it in the comments below and I’ll make sure that this one post rules them all 😉