36

My email address has changed and now I can't log into Visual Studio 2017.

The error is "We could not refresh the credentials for the account. Failed to refresh the access token".

enter image description here

How can I fix this?

JsAndDotNet
  • 16,260
  • 18
  • 100
  • 123

27 Answers27

56

This bug will be fixed in a future version.

For now:

  • Close down VS2017
  • Go to "C:\Users\{username}\AppData\Local\.IdentityService"
  • Rename "IdentityServiceAdalCache.cache" as shown below. (for example just add an underscore to it)
  • Restart VS2017 and log in. changing identityservice wile name

NOTE: There are similar issues that this won't resolve, but this worked for me.

stijn
  • 34,664
  • 13
  • 111
  • 163
JsAndDotNet
  • 16,260
  • 18
  • 100
  • 123
  • 3
    Not working by changing IdentityServiceAdalCache.cache or delete SessionTokens.json. But I make it work by turning AccountStore.json to public from hidden. –  Aug 14 '18 at 04:47
  • if you have trouble because you have changed e-mail/login name this solution will work. HOWEVER remember to restart visual studio. – Sebastian 506563 Jan 17 '19 at 11:53
  • Accountstore.json does not exist in that path for me. I couldn't find the file on Internet. How can I fix this problem? – Ferda-Ozdemir-Sonmez Feb 08 '19 at 11:48
  • I renamed AccountStore.json and logged in again - this fixed it for me. – aufty May 20 '19 at 18:14
  • 2
    I renamed the whole folder `.IdentityService` to `_.IdentityService` and it worked (VS 2019). Thanks! – Simon Arsenault Jun 03 '20 at 12:28
  • I am getting "We need to refresh the credentials for this account" in Visual Studio 2019! Ho to fix? I have tried the steps but no luck – kudlatiger Apr 06 '22 at 16:27
43

Open Visual Studio. Click Help, Send Feedback, Report a Problem...

This brings you to a login screen. If you log in from there, it will log you into Visual Studio.

Lauren Rutledge
  • 1,195
  • 5
  • 18
  • 27
Jedidiah May
  • 479
  • 4
  • 9
  • 8
    I was about to give up, but this worked for me, thanks. I have a long-standing problem that I set up a personal Hotmail account years ago along the form firstname.surname@mycompany.com, and my company then signed up for Office365 and I got a work account of exactly the same name. Microsoft's handling of these clashes has been a thorn in my side for years. The 'Report a Problem' hack worked for me and finally got VS to show me as logged in. – Rich Nov 21 '18 at 16:16
  • 1
    This worked for me. The problem itself may be related to Multi Factor Authentication. For the login box to work on feedback form, I had 1 app auth, followed by 2 text message auths to complete, then it worked. – adudley Dec 10 '18 at 14:25
  • 1
    I spent a long time trying to fix this issue, and tried signing in multiple ways, renamed json files, reset settings, even uninstalled and reinstalled vs. This worked and I cannot thank you enough for sharing it. Also, this was on a 2019 implementation. Thank you for sharing this solution! – COMCY2002 Mar 04 '20 at 04:43
  • For me, it is asking password again and again on reporting the problem – Amna Jul 22 '20 at 01:38
  • @Amna I haven't had the issue since updating to 2019 a while back. Might be worth possibly checking out. – Jedidiah May Aug 16 '20 at 21:32
  • Tried this, but I got "Error signing in: 'ERR_CERT_AUTHORITY_INVALID'" – Rye bread Aug 17 '20 at 12:59
8

What worked for me was to rename .identityservice and then restart VS and log in to your VSTS account. It then recreates a new .identityservice that it can access.

tarutao
  • 93
  • 1
  • 3
  • For clarification, this is renaming the .IdentityService FOLDER (renaming instead of deleting just in case it breaks something). Upon opening up VS and logging in it will recreate the .IdentityService folder. This worked for me! – Weston Mar 27 '19 at 21:14
8

I tried by deleting only the IdentityServiceAdalCache.cache as in the accepted answer but it did not fix the problem.

For the record, I managed to fix it by deleting every files within the .IdentityService folder (located in C:\Users{username}\AppData\Local.IdentityService).

Bertinchamps
  • 113
  • 1
  • 5
7

I have read dozens of posts on this topic discussing clearing out .IdentityService. I tried every variation of this solution that one might think of. None worked.

I ended up poking around and trying to manually login to my Microsoft account using Internet Explorer, but I could not connect to https://login.microsoftonline.com. I added the https://login.microsoftonline.com address to my Trusted Sites in Internet Options. Once I had done this, Visual Studio was able to connect to Microsoft and validate my account.

KnumSoft
  • 71
  • 1
  • 2
  • I also tried everything else, as adding sites to trusted meant making a group policy change at the AD level. However, this was indeed the only thing that resolved the issue for me. Thanks for the help! – cl0rkster May 01 '18 at 17:04
4
  • When an error occurs, Visual studio will log it's error messages in the following folder. Please check the logs located at

    %Temp%\servicehub\logs

  • This can also be caused by network restrictions. Please disable your virus guard or firewall and check.

Kusal Dissanayake
  • 714
  • 14
  • 32
4

This issue can also be caused by running VS "As Administrator" and the administrator is a different user. Just some FYI.

None of these answers will resolve that issue unfortunately.

Ed DeGagne
  • 3,250
  • 1
  • 30
  • 46
  • This is actually good point. For me nothing from above helped and this answer led me to try out one thing -> I was running VS on VM on administrator account. I made new administrator account on VM with same username as my host machine has. And woala, login allowed ... Thanks – Ademar Feb 21 '22 at 08:42
2

Very old thread but if someone is still having this issue, then try following in my footsteps:

I just deleted the entire .IdentityService folder, and launched visual studio again... It asks you to log in and works normally. (for me)

Spock445
  • 21
  • 1
1

Make sure you can access https://login.microsoftonline.com

If your network is blocking that (perhaps to block Microsoft webmail), then the above solutions will not pertain to you. Either unrestrict access, or you will need some off-line version.

Bort
  • 493
  • 1
  • 8
  • 26
1

In case someone is still looking for an answer. What worked for me was checking that the AppData folder and Local folder were not on 'read only mode' in the path "C:\Users{username}\AppData\Local.IdentityService" and it just worked!

Kekeletso
  • 11
  • 1
1
  • Check to make sure that your PC no limit(IP-Firewall) to Internet connection access.
  • Disable or turn off VPN
MohammadSoori
  • 2,120
  • 1
  • 15
  • 17
1

It happened to me when using an account that uses my organization's email-domain, and I guess it tried to verify it and it couldn't find it in their database, and as soon as I used an account with a onmicrosoft.com domain, it worked.

The interesting part is that it allowed me to create the Microsoft account with this organization email and I still use it for DevOps, and it just stopped me when signing in with Visual Studio, I don't understand why this difference is.

I hope this can help someone..

Mayer Spitz
  • 2,577
  • 1
  • 20
  • 26
1

I have VS 2017 and had this exact issue. Simply deleting
C:\Users\{username}\AppData\Local.IdentityService did not work for me.

Follow the steps 1-2 below to see if you might have and identical cause of the problem, and the rest how to solved it if so.

  1. Go to C:\Users\{user}\AppData\Local\Temp\servicehub\logs and open the latest error logs from VS.

  2. IF you see "Retrieved tenant memberships, found '2' owned tenants", then follow the rest of the steps.

  3. Go to azure portal then login under the username you are trying to use.

  4. The following steps may change by the time you read this, but you want to get to step 6. Go to Manage Azure Directory.

  5. Click "Switch Tenants"

  6. I was linked to 2 tenants, one of which I did not need. This is what had been causing my issues. Select the useless tenants, and click "leave tenant".

  7. Once this is completed, close all instances of VS.

  8. Delete C:\Users\{username}\AppData\Local.IdentityService.

  9. Open VS and login to your account.

James Risner
  • 5,451
  • 11
  • 25
  • 47
f_Me123
  • 11
  • 1
0

I found the same behavior when using Administrator user. Any other user can login and activate the license only for himself. I don't think there is a way to activate for Administrator, which makes using this licensing awkward for usage in a shared resource (i.e. build server).

lkanab
  • 924
  • 1
  • 7
  • 20
0

The one solution which worked for me was resetting the domain password and restarting the system. I just wanted to share this because i was struggling with the same problem since 8 days tried everything on net and this worked. Hope it helps someone :)

harsh
  • 21
  • 4
0

I updated Visual Studio with latest package and after rebooting my PC issue was solved. I was able to log-in

Andrej Gaspar
  • 231
  • 2
  • 8
0

Opening VS as admin worked for me, none of the above did

Marciel Fonseca
  • 371
  • 1
  • 4
  • 19
0

I was getting this error from our proxy having restrictive rules in place, I was able to add the sites to a whitelist that were being blocked while trying to login.

Some of the sites I whitelisted in Webmarshal were:

  • *.windows.net
  • *.msocsp.com
  • *.ws.symantec.com
  • *.digicert.com
  • *.clicktale.net
  • app.vssps.visualstudio.com
  • demdex.net
Thomas Youngson
  • 181
  • 3
  • 14
0

For me it was due wrong system time, after setting correct time it got fixed automatically

vinay
  • 1
0

I had the problem of not being able to sign in to VS after not using unity for a long time and then updating everything. The way I solved it was to open VS and then click help. This opened the sign in box with 'Personalization Account'. I clicked 'Account options' under the afore mentioned heading, and changed the 'Embedded web browser' to 'System web browser' in the right window. This enabled me to log in via my Edge browser and everything worked fine.

Oliver Marienfeld
  • 1,154
  • 9
  • 17
Adam
  • 1
0

I just fixed it by changing folder to be public. folder files: "C:\Users{username}\AppData\Local.IdentityService" right click and choose property and uncheck the hidden and apply it.

0

If you are under a domain network there is a workaround (quick fix),

Adding or changing the following key

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\Protect\Providers\df9d8cd0-1501-11d1-8c7a-00c04fc297eb

ProtectionPolicy = 1 (DWORD)

Check the most recent modified files at %temp%\servicehub\logs.

Check StorageUtilitiesSingleton-10788-lqnuymos-1.log

For an error like this: The computer must be trusted for delegation and the current user account must be configured to allow delegation.

If that is the case this might help you.

Jonathan
  • 1,955
  • 5
  • 30
  • 50
CamiloSDA
  • 15
  • 4
0

I has this issue recently.

Tried all the options above, none worked.

Get it sorted, after repairing Visual Studio, doing all the updates, restart and updated again, restart, another repair and bang! Worked like a charm.

0

Instead of doing all this, change embedded broswer to system browser so it will works normally in default browser and gets updated in VS.

0

In VS 2019 enabling System Web Browser instead of Embedded web browser fixed it for me,

Hope this helps someone https://learn.microsoft.com/en-us/visualstudio/ide/work-with-multi-factor-authentication?view=vs-2019

Ahmad Hajou
  • 1,289
  • 5
  • 22
  • 39
0

I tried multiple things above such as

  • Renaming c:\users[user]\appdata\local.IdentityService
  • Logging directly in https://login.microsoftonline.com (noticed certificate issues)
  • Adding https://login.microsoftonline.com to the Trust Sites list in Internet Options
  • Opening VS as non-admin as well as admin
  • Reviewed the logs here: %Temp%\servicehub\logs
  • I also installed Chrome, setting it to the default browser, because many features were saying IE is no longer supported

Reviewing the logs gave me the clue I needed to solve my particular issue. The log stated there was an issue with SSL trust.

Consequently, I ran our local version of rootsupd.exe and installed any related Microsoft root certificates such as the DigiCert Global Root G2 to the Trusted Root Authorities. After rebooting my machine, I noticed VS began recognizing my account and was actually already signed in.

0

Enabling TLS 1.2 in internet options solved the problem for me. Search "Enable TLS 1.2 in Internet Explorer 8, 9 or 10"