在我们的应用程序中,我们想要检索访问 token 。使用此 token ,我们希望使用 Azure DevOps Rest API 5.1 执行某些操作。
我已经尝试了 Microsoft 针对 OAuth2 ( https://learn.microsoft.com/en-us/azure/devops/integrate/get-started/authentication/oauth?view=azure-devops ) 和 PAT 的建议文档。结果总是返回 203 响应。有人知道这个问题的解决方法吗?
最佳答案
根据我的测试,我们可以使用 Azure Ad 访问 token 调用 Azure DevOps Rest API。欲了解更多详情,请引用以下步骤 1. 注册 Azure AD 应用程序
# get code
GET https://login.microsoftonline.com/{tenant}/oauth2/authorize?
client_id=<your app client id>
&response_type=code
&redirect_uri=<>
&response_mode=query
&resource=499b84ac-1321-427f-aa17-267ca6975798
&state=12345
#Get token
Post https://login.microsoftonline.com/{tenant}/oauth2/token
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code
&client_id=<>
&code=<>
&redirect_uri=https%3A%2F%2Flocalhost%3A12345
&resource=499b84ac-1321-427f-aa17-267ca6975798
&client_secret=<>
关于c# - 检索 Azure DevOps REST API 5.1 的 Accesstoken,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59609591/