Azure Devops REST API - 使用 PAT - 返回重定向对象已移动

Ric*_*ino 1 azure-devops azure-devops-rest-api

我在使用控制台应用程序验证 Azure Devops API 时遇到问题

在 AzureDevOps 上调用 Get Projects API 后,我得到一个重定向...到登录页面

curl -u :${B64_PAT} "https://dev.azure.com/xxxxxxxxxxxx/_apis/projects?api-version=6.0"
Run Code Online (Sandbox Code Playgroud)

返回:

<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="https://spsprodsbr1.vssps.visualstudio.com/_signin?rea
Run Code Online (Sandbox Code Playgroud)

我需要从“Java 服务器应用程序”调用此 API,但返回登录页面时遇到问题。但我想遵循设备身份验证流程

Joy*_*ang 6

我可以在我这边重现您的问题,要解决该问题,请将您的 PAT 直接传递给命令,而不进行 Base64 编码。

curl -u :<PAT> "https://dev.azure.com/xxxxxxxxxxxx/_apis/projects?api-version=6.0"
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述