其他分享
首页 > 其他分享> > 【Azure Developer】CURL 发送Oauth2 Token请求获取到 404 Not Found 问题

【Azure Developer】CURL 发送Oauth2 Token请求获取到 404 Not Found 问题

作者:互联网

问题描述

当使用 Postman 向AAD 发送如下请求时候,得到了404 Not Found的错误。

 

"curl --location --request POST 'https://login.chinacloudapi.cn//oauth2/token' \

--header 'Content-Type: application/x-www-form-urlencoded' \

--data-urlencode 'grant_type=client_credentials' \

--data-urlencode 'client_id=' \

--data-urlencode 'client_secret=' \

--data-urlencode 'resource=https://management.chinacloudapi.cn'" 

 

问题分析

404 表示所请求的URL有错误, 查看以上命令使用的为  'https://login.chinacloudapi.cn//oauth2/token'  ,发现在Oauth2之前,缺少了AAD的Tenant ID信息。所以,完整的Token URL应是:

https://login.chinacloudapi.cn/{Tenant ID}/oauth2/token

在AAD门户中Tenant ID 及正确的Token URL为:

 

 

 

标签:urlencode,Oauth2,cn,--,Token,404,chinacloudapi,https,data
来源: https://www.cnblogs.com/lulight/p/15837056.html