当前位置 : 主页 > 编程语言 > java >

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

来源:互联网 收集:自由互联 发布时间:2022-09-02
问题描述 当使用 Postman 向AAD 发送如下请求时候,得到了404 Not Found的错误。 "curl --location --request POST 'https://login.chinacloudapi.cn//oauth2/token' \ --header 'Content-Type: application/x-www-form-urlencoded'

问题描述

当使用 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为:

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

 

 

 

当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!



网友评论