使用Bearer Token调用Azure DevOps REST API列出PAT时遇203错误求助
错误根源:生成Bearer Token时指定的
resource参数错误。你当前使用的https://management.azure.com/是Azure管理API的资源标识,但调用Azure DevOps令牌API需要指向Azure DevOps专属的资源,正确的资源值应为https://dev.azure.com/(若针对特定组织,也可使用https://<你的组织名>.visualstudio.com/)。修正后的Token请求:
将POST请求中的resource字段替换为正确值,示例如下:POST https://login.microsoftonline.com/<tenantID>/oauth2/token grant_type:client_credentials client_id: <appID> client_secret: <secret> resource: https://dev.azure.com/额外配置要求:
- 确保你的服务主体(即
client_id对应的应用)在目标Azure DevOps组织中被授予**Token Management (Read)**权限,可通过组织设置的“权限”页面完成配置。 - 调用PAT列表API时,需使用正确的请求格式:
GET https://vssps.dev.azure.com/{organization}/_apis/tokens/pats?api-version=7.0 Authorization: Bearer <修正后的令牌>
- 确保你的服务主体(即
内容的提问来源于stack exchange,提问作者Uday Kiran
相关产品推荐
相关产品推荐

