【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为:

 

 

 

posted @   路边两盏灯  阅读(563)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
历史上的今天:
2021-01-23 【Azure Developer】已发布好的.NET Core项目文件如何打包为Docker镜像文件
点击右上角即可分享
微信分享提示