我们正在迁移一些代码,这些代码以前运行在on服务器上,但现在需要在Azure DevOps (以前的Team )上运行。我使用的凭据已被验证以成功身份验证到我们的DevOps组织实例,但在引用
Microsoft.TeamFoundationServer.ExtendedClient
NuGet包总是导致TF30063: You are not authorized to access https://dev.azure.com/<myOrg>,代码发布在下面,以便通过非交互式身份验证进行身份验证。是否需要使用不同的身份验证机制或不同的凭据类型才能使此工作?
System.Net.NetworkCredential networkCredential = new System.Net.NetworkCredential(_userName, DecryptedPassword, _domain);
try
{
// Create TeamFoundationServer object
_teamFoundationCollection = new TfsTeamProjectCollection(_serverUrl, networkCredential);
_teamFoundationCollection.Authenticate();
}
catch (Exception ex)
{
// Not authorized
throw new TeamFoundationServerException(ex.Message, ex.InnerException)
}发布于 2019-05-06 06:06:45
由于您希望使用.Net客户端库,因此可以参考以下链接:
供使用的模式:
using Microsoft.VisualStudio.Services.Common;
using Microsoft.VisualStudio.Services.Client;
using Microsoft.TeamFoundation.SourceControl.WebApi;
using Microsoft.VisualStudio.Services.WebApi;
const String c_collectionUri = "https://dev.azure.com/fabrikam";
const String c_projectName = "MyGreatProject";
const String c_repoName = "MyRepo";
// Interactively ask the user for credentials, caching them so the user isn't constantly prompted
VssCredentials creds = new VssClientCredentials();
creds.Storage = new VssClientCredentialStorage();
// Connect to Azure DevOps Services
VssConnection connection = new VssConnection(new Uri(c_collectionUri), creds);
// Get a GitHttpClient to talk to the Git endpoints
GitHttpClient gitClient = connection.GetClient<GitHttpClient>();
// Get data about a specific repository
var repo = gitClient.GetRepositoryAsync(c_projectName, c_repoName).Result;https://stackoverflow.com/questions/55975759
复制相似问题