C# – Visual Studio Online TF30063: You are not authorized to access

azure-devopsc

I am trying to connect to my Visual Studio Online account, via web api. Following the steps here for here:

http://blogs.msdn.com/b/buckh/archive/2013/01/07/how-to-connect-to-tf-service-without-a-prompt-for-liveid-credentials.aspx

NetworkCredential netCred = new NetworkCredential(
    "myaccount@gmail.com",
    "mypassword");
BasicAuthCredential basicCred = new BasicAuthCredential(netCred);
TfsClientCredentials tfsCred = new TfsClientCredentials(basicCred);
tfsCred.AllowInteractive = false;

TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(
    new Uri("https://myaccount.visualstudio.com/DefaultCollection"),
    tfsCred);

tpc.EnsureAuthenticated();
Console.WriteLine(tpc.InstanceId);

However I get the following error message:

TF30063: You are not authorized to access .visualstudio.com

Best Answer

After trying every coding option in the book, I turned to an alternative approach:

Logged out of Visual Studio Online from:

  • Browser(s)
  • Browser within Visual Studio IDE
  • Cleared my cache from C:\Users\ [your username] \AppData\Local\Microsoft\Team Foundation\5.0\Cache

and it worked...:)

Related Topic