'Team Foundation Server - Unauthorized intermittently

Recently I've had this error pop up intermittently when trying to do things in a project:

  1. Checking In Changes
  2. Making edits to a recently unchanged file (checking out a file I assume)
  3. Opening Source Control Explorer

enter image description here

After a couple of tries or reloads it end up working. But, it's really annoying and just started happening.

  1. I tried clearing Internet Explorer browser history.
  2. I tried changing the login type microsoft.com/devicelogin.
  3. I tried clearing Visual Studio cache. (not sure if i cleared everything)

Side Note: I changed the name of my laptop recently and that seems to be around the same time I started having issues, not sure if that is related.

The same thing happens when using Visual Studio 2019 and 2022 community versions.

Any help would be appreciated. Thank you!



Solution 1:[1]

Try clear both local TFS cache and Visual Studio Cache, then try it again.

?1. Close all Visual Studio instances. 2. clear visual studio cache under

%APPDATA%\Microsoft\VisualStudio
  1. clear TFS cache under

%LocalAppData%\Microsoft\Team Foundation\{version}\Cache

  1. Go to Control Panel -> User Accounts -> Manage your Credential -> Windows Credential, select the TFS url to remove it.
  2. Restart your Visual Studio to re-connect to your TFS Server.

If that still not work, just try adding following code to your TFS web.config file (C:\Program Files\Microsoft Team Foundation Server 14.0\Application Tier\Web Services\web.config):

<configuration>
      <system.net>
            <settings>
                  <httpWebRequest useUnsafeHeaderParsing="true"/>
            </settings>
      </system.net>
</configuration>

UPDATE:

Try below things :

  • Run below command to reset the user data, then try it again.

    cd C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE, devenv.exe /resetuserdata

  • Try run as another user with command: runas /netonly /user:<account> devenv.exe

  • Reset IIS and application pool

If that still not work, I suggest removing the VS first (clean uninstall), then reinstall it again..

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1