首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无法使用TFS扩展客户端版本15访问https://dev.azure.com/<myOrg>

无法使用TFS扩展客户端版本15访问https://dev.azure.com/<myOrg>
EN

Stack Overflow用户
提问于 2019-05-03 19:02:52
回答 1查看 37关注 0票数 0

我们正在迁移一些代码,这些代码以前运行在on服务器上,但现在需要在Azure DevOps (以前的Team )上运行。我使用的凭据已被验证以成功身份验证到我们的DevOps组织实例,但在引用

Microsoft.TeamFoundationServer.ExtendedClient

NuGet包总是导致TF30063: You are not authorized to access https://dev.azure.com/<myOrg>,代码发布在下面,以便通过非交互式身份验证进行身份验证。是否需要使用不同的身份验证机制或不同的凭据类型才能使此工作?

代码语言:javascript
运行
复制
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)
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-05-06 06:06:45

由于您希望使用.Net客户端库,因此可以参考以下链接:

https://learn.microsoft.com/en-us/azure/devops/integrate/concepts/dotnet-client-libraries?view=azure-devops

供使用的模式:

代码语言:javascript
运行
复制
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;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55975759

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档