c# - VS30063 : You are not authorized to access https://dev. 蔚蓝网

标签 c# asp.net-core-2.1 azure-devops-rest-api tfs-sdk

我正在尝试在 asp.net core(2.1) mvc 应用程序中使用以下代码连接 Azure DevOps

Uri orgUrl = new Uri("https://dev.azure.com/xxxxx/");          
String personalAccessToken = "xxxxx";  
VssConnection connection = new VssConnection(orgUrl, new VssBasicCredential(string.Empty, personalAccessToken));

但收到此错误 "VssUnauthorizedException: 'VS30063: You are not authorized to access https://dev.azure.com.'"

相同的代码在 .net 核心控制台应用程序中工作,有人可以帮我解决这个问题吗?

在我的代码中,我正在尝试获取工作项,但在 GetClient 上出现错误 enter image description here

最佳答案

您的代码没有错误。

VS30063: You are not authorized to access https://dev.azure.com.

这是未经授权的错误代码。应该是你的 PAT token 不可用造成的。通过使用您的代码,如果我使用过期的 token ,将收到相同的错误。

enter image description here

生成新的 PAT token 后,错误消失,代码成功运行。

因此,只需尝试从 Azure Devops 生成一个新 token 并使用它。

更新:

使用更新问题的屏幕截图中的关键代码,我创建了一个完整的应用程序来写入 WIQL 结果。仍然成功如下图:

enter image description here

你能执行你的代码并分享错误截图吗?(注:仅针对错误行)

关于c# - VS30063 : You are not authorized to access https://dev. 蔚蓝网,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57766867/

相关文章:

c# - 静态文件中间件应该在 ASP.NET Core 管道中的什么位置?

templates - 如何在 ASP.NET Core 2.1 中向 Visual Studio 添加新的 Razor 页面模板?

azure-devops - 如何在 VSTS API 中删除带注释的标签(git 标签)?

azure - Windows 命令提示符curl POST 运行 Azure DevOps 管道

C# - 如何使用递归确定两个字符串是否只有一个共同的字母

c# - 如何在 xaml 中将空字符串指定为目标空值

c# - Linq to Xml,是否可以改进此查询?

c# - 控制名称格式的 XSD 到 C# 类

c# - .net Core 在配置不同的配置提供程序时访问 appsettings.json

azure - 如何使用 API 或 CLI 获取 Azure Devops 项目中的用户列表