TF31001: Cannot connect to Team Foundation Server at .visualstudio.com.
The server returned the following error: Key not valid for use in specified state
Expired token due to change in Windows credentials (Active Directory for Enterprise hosted TFS and Live credentials for Visual Studio Online)
Team Foundation Server when using Visual Studio 2013 stores token based on Windows credentials (Active Directory / Live credentials) in Windows Registry. For example, I’m connected to 2 Visual Studio Online repositories, so you can see 2 keys in VssApp
Now when you change the credentials, in most cases this error will not come as Visual Studio will try to re-authenticate you and update the token. However in case of any failures, you may get the error TF31001.
To resolve this,
- Close all instances of Visual Studio
- Run Task Manager and find out all TFS services. Click on End Process Tree to shut down all the services
- Delete just the TokenStorage folder:
- Restart Visual Studio and retry