1
votes

I'm trying to connect to our online TFS. This is what I currently have:

NetworkCredential cred = new NetworkCredential(textBox_Username.Text, 
    textBox_password.Password);
Uri TFSurl = new Uri("https://myCompany.visualstudio.com/DefaultCollection");
TfsConfigurationServer tfs = new TfsConfigurationServer(TFSurl, cred);
tfs.EnsureAuthenticated();

This throws me :

TF30063: You are not authorized to access https://actacom.visualstudio.com/DefaultCollection.

The Credentials entered are correct.

2

2 Answers

1
votes

Check this blog post, it has a sample code on how to do it. I've tried it with my VSO account and it worked just fine.

0
votes

The blog helped me out. For other people, here is the working code.

 NetworkCredential netCred = new NetworkCredential(
                textBox_Username.Text,
                textBox_password.Password);
                BasicAuthCredential basicCred = new BasicAuthCredential(netCred);
                TfsClientCredentials tfsCred = new TfsClientCredentials(basicCred);
                tfsCred.AllowInteractive = false;

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

                tpc.Authenticate();