我正在尝试使用 Postman 从 Azure Devops 使用 OAuth 身份验证来调用 REST API。 但是,它给了我错误。
PFA APP 截图,以及
请有人告诉我端到端的身份验证过程并获取访问令牌。
我曾尝试制作应用程序并使用类似 -
的凭据但是,仍然无法获取。 请帮忙
这是在 Azure Devops 端打开以获取身份验证的页面的屏幕截图 - 接受/拒绝,但在我接受之后 - 它出现错误。
我可以按照
文档中的步骤获取
access_token
。
这是我的步骤。
2. 使用应用程序 ID 和您在应用程序中使用的授权回调 URL 对应用程序进行授权。
https://app.vssps.visualstudio.com/oauth2/authorize
?client_id={app ID}
&response_type=Assertion
&state=User1
&scope=vso.work_full
&redirect_uri={your Authorization callback URL}
完成以上网址后,将其粘贴到浏览器中,然后单击 Enter。
它需要您接受该应用程序。
我们接受后,它会将浏览器重定向到回调 URL,包括短暂的授权代码和授权 URL 中提供的状态值。我们将在下一步中使用该代码。
https://jwt.ms/?code=**eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Im.......**&state=User1
POST https://app.vssps.visualstudio.com/oauth2/token
获取访问和刷新令牌 正文 Content-Type
是 application/x-www-form-urlencoded
。身体细节:
client_assertion_type:urn:ietf:params:oauth:client-assertion-type:jwt-bearer
client_assertion:{client secret acquired when the app was registered}
grant_type:urn:ietf:params:oauth:grant-type:jwt-bearer
assertion:{"code" provided via the code query parameter to your callback URL}
redirect_uri:{callback URL registered with the app}
access_token
,我们可以在postman中使用它来获取工作项的详细信息。我的测试结果:
grant_type
更改为 refresh_token
,然后将 assertion
更改为您在步骤 4 中获得的“refresh_token”。身体细节:
client_assertion_type:urn:ietf:params:oauth:client-assertion-type:jwt-bearer
client_assertion:{client secret acquired when the app was registered}
grant_type:refresh_token
assertion:{"refresh_token" in step 4}
redirect_uri:{callback URL registered with the app}
我的测试结果: