The Problem: Automation with VSO
If you try to automate things with Visual Studio Online (VSO), you’ll run into authentication problems.
Here’s why. You access VSO with a Microsoft Account. To sign-in to that account, you have to put your username and password into a pop-up window from Microsoft.
BUT… that doesn’t work for automation, because there’s nobody to type in the info.
So Microsoft added this thing called Alternate Authentication Credentials (AAC). This is part of the Microsoft Account that you can enable in the Account Settings. You can use the alternate username and password with basic authentication.
And while that’s cool in theory, I was constantly running into problems. It was partly because I didn’t originally know about AAC, partly for other reasons. It’s a long story. But anyway, I ended up testing a bunch of different ways of using AAC.
The Solution: Using the Right Password
Here’s the fix I came up for my situation.
- Use a different password from your primary account password. Otherwise you’ll get authentication errors in Visual Studio.
- And, if you’re going to leave the secondary username unset and change your secondary password, remove your VSO credentials from Windows Credential Manager. Otherwise, you’ll also get authentication errors.
On #2, I got this error specifically when I was trying to do stuff with VSO in Visual Studio:
Team Foundation Error
Type ‘Microsoft.TeamFoundation.Client.BasicAuthCredential’ in assembly ‘Microsoft.TeamFoundation.Client, Version=220.127.116.11, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ is not marked as serializable.
And even more specifically, I got this constantly when accessing the Process page of a Build Definition. (On other stuff it went away after I tried some things.)
It was also weird on #2 because when I deleted the credential cache, Visual Studio logged me into VSO with no prompt and no problems. So I guess it still had my primary account cached. But until I deleted the secondary from the cache, it wouldn’t use it.
There may be some other caveats – I ran into a lot of problems trying to setup automated builds and tests with Java, Build Extensions, and TEE – but I’ll save that for another article since it’s specific to that scenario.
Well, that’s it – hope this helps! If it did – or even if it didn’t – please leave a message in the comments below.
Author: Tomas Ramirez
Tomas is a software developer turned QA manager. At Windward, he has developed and deployed solutions from end to end -- everything short of doing the sales calls.
Other posts by Tomas Ramirez