alok_dida
alok_dida

Reputation: 1723

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

I am trying to connect to TFS and authenticate user using below code. But I am getting the error:

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

var netCred = new NetworkCredential("[email protected]", "password");
                var windowsCred = new WindowsCredential(netCred);
                var tfsCred = new TfsClientCredentials(windowsCred);
                tfsCred.AllowInteractive = false;
                var tpc = new TfsTeamProjectCollection(tfsUri, tfsCred);
                tpc.Authenticate();

When I am running below code it's prompting windows where i have to enter credentials.

var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("https://test.visualstudio.com/DefaultCollection"));
            var store = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));

This application is going to utilize by external people and I need silent login to TFS.

I saw one below solution but i can't ask every user to do that.

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

Please suggest me some solution.

Upvotes: 3

Views: 3351

Answers (1)

jessehouwing
jessehouwing

Reputation: 114461

Your users will have to log on using the Live ID/MSA once and they can check the box that saves their credentials so that they won't be prompted in the future. In the future Visual Studio Online will probably move towards a solution that uses Azure Active Diectory/Azure Access Control Services which will allow you to use other credential types as well, for now you either need to have your users enable Basic Authentication or have them authenticate to VSO once and have them check the "Save Credentials" checkbox so that they're not prompted in the future.

Uri collectionUri = new Uri("https://youraccount.visualstudio.com:443/defaultcollection");
UICredentialsProvider credentialProvider = new UICredentialsProvider();
var tfs = TfsTeamProjectCollectionFactory
               .GetTeamProjectCollection(collectionUri, new UICredentialsProvider());
tfs.EnsureAuthenticated();

If you want to connect using the Basic Credentials, you can also use this code (after enabling Basic Credentials for the account you want to use):

NetworkCredential netCred = new NetworkCredential(
    "[email protected]",
    "password");
BasicAuthCredential basicCred = new BasicAuthCredential(netCred);
TfsClientCredentials tfsCred = new TfsClientCredentials(basicCred);
tfsCred.AllowInteractive = false;

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

tpc.Authenticate();

Upvotes: 3

Related Questions