【问题标题】:TF30063: You are not authorized to access https://dev.azure.com/MyProjectTF30063:您无权访问 https://dev.azure.com/MyProject
【发布时间】:2019-12-12 18:43:33
【问题描述】:

我正在尝试使用 VS 2017 将我的项目连接到 Azure DevOps。 原因:从本地 DevOps 迁移到 Azure-DevOps。 错误:TF30063:您无权访问https://dev.azure.com/MyProject 登录:两因素身份验证。 如何使用 VS 2017 在 Azure DevOps 中为我的项目创建测试计划?

我已经在 VS 2017 中连接了 Azure-DevOps,并且可以使用浏览器(Visual Studio、View->Other Windows->Web Browser)查看我的项目。但是使用代码我无法访问

NetworkCredential netCred = new NetworkCredential("username@mail.com", "password");
BasicAuthCredential basicCred = new BasicAuthCredential(netCred);
TfsClientCredentials tfsCred = new TfsClientCredentials(basicCred);
tfsCred.AllowInteractive = false;

TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri(_newServer), tfsCred);

 tpc.EnsureAuthenticated();
 tpc.Authenticate();

Log in with two factor authentication

【问题讨论】:

  • 我确实清理了缓存 TFS 文件夹

标签: c# tfs visual-studio-2017 azure-devops


【解决方案1】:

您不能直接使用邮件帐户,请改用备用凭据 (https://dev.azure.com/{org}/_usersSettings/altcreds)。

或者您可以使用个人访问令牌

VssCredentials Credentials = new VssCredentials(new Microsoft.VisualStudio.Services.Common.VssBasicCredential(string.Empty, "your personal acccess token"));
            TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri("https://dev.azure.com/{org{"), Credentials);

您还可以在运行时指定电子邮件帐户:

TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri("https://{org}.visualstudio.com"), new VssClientCredentials());

NuGet 包:Microsoft.TeamFoundationServer.ExtendedClient

【讨论】:

  • 它仅适用于“备用凭据”。谢谢
【解决方案2】:

考虑使用Microsoft.TeamFoundationServer.Client nuget 包。请尝试以下步骤:

string PAT = "<your_pat>";
VssConnection connection = new VssConnection(new Uri("<your_url>"), new VssBasicCredential(string.Empty, PAT));
TestPlanClient = Connection.GetClient<TestPlanHttpClient>();
  • 然后你可以创建一个测试计划
TestPlanCreateParams newPlanDef = new TestPlanCreateParams()
{
    Name = TestPlanName,
    StartDate = StartDate,
    EndDate = FinishDate,
    AreaPath = AreaPath,
    Iteration = IterationPath
};

var test_plan =  TestPlanClient.CreateTestPlanAsync(newPlanDef, TeamProjectName).Wait();

【讨论】:

猜你喜欢
  • 2020-01-06
  • 2020-06-19
  • 2019-08-14
  • 1970-01-01
  • 2018-09-27
  • 2017-03-31
  • 1970-01-01
  • 2013-11-07
相关资源
最近更新 更多