检索Azure DevOps REST API 5.1的Accesstoken [英] Retrieve Accesstoken for Azure DevOps REST API 5.1

查看:66
本文介绍了检索Azure DevOps REST API 5.1的Accesstoken的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的应用中,我们想要检索一个访问令牌.使用此令牌,我们希望使用Azure DevOps rest API 5.1执行某些操作.

我已经尝试过从Microsoft针对OAuth2进行建议的文档化(

  1. 配置应用程序

    a.创建客户机密

    b.配置权限

  2. 获取令牌

 #获取代码GET https://login.microsoftonline.com/{tenant}/oauth2/authorize?client_id =<您的应用程序客户端ID>& response_type =代码& redirect_uri =<>& response_mode =查询& resource = 499b84ac-1321-427f-aa17-267ca6975798& state = 12345#获取令牌发布https://login.microsoftonline.com/{tenant}/oauth2/token内容类型:application/x-www-form-urlencodedgrant_type =授权码& client_id =<>& code =<>& redirect_uri = https%3A%2F%2Flocalhost%3A12345& resource = 499b84ac-1321-427f-aa17-267ca6975798& client_secret =<> 

  1. 通话休息API

In our app we want to retrieve an accesstoken. With this token we want to perform certain actions with Azure DevOps rest API 5.1.

I've tried the suggested documententation from Microsoft for OAuth2 (https://docs.microsoft.com/en-us/azure/devops/integrate/get-started/authentication/oauth?view=azure-devops) and PAT's. This always gives back a 203 response as an result. Does somebody know a workaround for this issue?

解决方案

According to my test, we can call Azure DevOps rest API with Azure Ad access token. For more details, please refer to the following steps 1. Register an Azure AD application

  1. Configure applications

    a. Create client secret

    b. Configure permissions

  2. Get token

 # 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=<>

  1. Call Rest API

这篇关于检索Azure DevOps REST API 5.1的Accesstoken的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆