VSTS Authenticating with vssClientCredentials

2019-06-03 08:16发布

I am currently trying to connect to a VSTS project using the code below, I have previously connected successfully after entering credentials into the dialog box shown.

if (!IsConnected)
{
    sourceControl = release.SourceControl;
    connection = new VssConnection(new Uri(sourceControl), new VssClientCredentials());
    workItemTrackingHttpClient = connection.GetClient<WorkItemTrackingHttpClient>();
}

The dialog box is no longer shown and an exception is thrown:

TF400813: Resource not available for anonymous access. Client authentication required.

I am unaware of any changes that could have caused this to break, any help would be greatly appreciated.

1条回答
再贱就再见
2楼-- · 2019-06-03 08:36

You can delete the cached credential from registry: Computer\HKEY_CURRENT_USER\Software\Microsoft\VSCommon\14.0\ClientServices\TokenStorage\VisualStudio (delete VssApp key)

You also can specify the credential storage:

var c = new VssClientCredentials();
c.Storage = new VssClientCredentialStorage(storageKind: "VssApp2", storageNamespace: "VisualStudio");
connection = new VssConnection(new Uri(sourceControl), c);
查看更多
登录 后发表回答