Azure DevOps 客户端 SDK:使用 TestManagementHttpClient.GetTestResultsByBuildAsync2 会引发身份验证错误

问题描述 投票:0回答:2

我正在使用用于 Azure DevOps 的 .NET 客户端库来从构建尝试中获取测试结果。以下抛出身份验证错误,Microsoft.VisualStudio.Services.Common.VssUnauthorizedException: VS30063: You are not authorized to access https://dev.azure.com.


var testClient = connection.GetClient<TestManagementHttpClient>(); var testResults = await testClient.GetTestResultsByBuildAsync2( project: project, buildId: ID);
我使用的 PAT 的作用范围是读取和执行构建和测试。不知道为什么我会收到此错误。还有其他方法可以获取每次尝试的测试结果吗?我可以使用相同的连接来调用 

GetTestResultDetailsForBuildAsync

,但不幸的是,它列出了所有尝试的结果,我只需要最后一个。

azure-devops azure-sdk-.net
2个回答
0
投票
尝试以下任一方法来解决

Microsoft.VisualStudio.Services.Common.VssUnauthorizedException: VS30063: You are not authorized to access https://dev.azure.com.

 错误:

  1. 按照

    Marina Liu的建议清理缓存:执行 regedit

     -> 清除下面的键
    
    HKEY_CURRENT_USER\Software\Microsoft\VSCommon\14.0\ClientServices\TokenStorage\VisualStudio\VssApp
    -> 重新启动 VS -> 使用您自己的凭据运行您的项目。

  2. 检查个人访问令牌是否已过期或使用正确的范围创建

参考:

VS30063:您无权访问 https://dev.azure.com?尝试使用 PAT 令牌在 Azure DevOps 项目中注册专用代理池时出错 - Microsoft Q&Ac# - VS30063:您无权访问 https://dev.azure.com - Stack OverflowVisual Studio 反馈


0
投票
我遇到了同样的问题,但所有建议都没有帮助。我还可以调用其他一些方法,但不能调用

GetTestResultsByBuildAsync

。
幸运的是,我注意到有不同类型的客户:

TestResultsHttpClient testClient1 = connection.GetClient<TestResultsHttpClient>(); TestManagementHttpClient testClient2 = connection.GetClient<TestManagementHttpClient>();
如果我使用

testClient1

,那么调用下面的代码工作正常,但当我使用
testClient2
时,会因身份验证错误而失败。:

List<ShallowTestCaseResult> allTestResults = await testClient.GetTestResultsByBuildAsync(ProjectName, buildId);
请尝试使用

TestResultsHttpClient

代替
TestManagementHttpClient

© www.soinside.com 2019 - 2024. All rights reserved.