使用“Expose an API”范围请求令牌时发生错误。AADSTS70011:The 为输入参数 'scope' 提供的值无效
An error occurred while requesting the token with "Expose an API” scope. AADSTS70011:The provided value for the input parameter 'scope' is not valid
我添加了scope to "Expose an API" on the Azure portal with the reference of Microsoft document and granted API permission to that scope. After that I request a token using postman它returns一个错误AADSTS70011: The provided request must include a 'scope' input parameter. The provided value for the input parameter 'scope' is not valid.
当我尝试这样的范围时 {resource}/.default
工作正常。但是,我需要像 {resource}/access_as_user
这样的范围
我已经尝试过这个,但是没有用。
您使用了错误的身份验证流程,并授予了 delegated permissions
。在这种情况下,您应该使用 auth code flow.
那么你可以设置scope为:api://{resource}/access_as_user
.
加:
这是我的测试过程:
- 首先在浏览器中获取授权码:
https://login.microsoftonline.com/xxxxxxxx-bd27-40d5-8459-230ba2a757fb/oauth2/v2.0/authorize?
client_id=5f11e827-xxxx-4f1f-aa05-33a33f806aab
&response_type=code
&redirect_uri=https://jwt.ms/index
&response_mode=query
&scope=api://c848e37d-xxxx-4cd8-b9bf-0b2aa6927a82/access_as_user
&state=12345
- 使用授权码兑换访问令牌:
我添加了scope to "Expose an API" on the Azure portal with the reference of Microsoft document and granted API permission to that scope. After that I request a token using postman它returns一个错误AADSTS70011: The provided request must include a 'scope' input parameter. The provided value for the input parameter 'scope' is not valid.
当我尝试这样的范围时 {resource}/.default
工作正常。但是,我需要像 {resource}/access_as_user
我已经尝试过这个
您使用了错误的身份验证流程,并授予了 delegated permissions
。在这种情况下,您应该使用 auth code flow.
那么你可以设置scope为:api://{resource}/access_as_user
.
加:
这是我的测试过程:
- 首先在浏览器中获取授权码:
https://login.microsoftonline.com/xxxxxxxx-bd27-40d5-8459-230ba2a757fb/oauth2/v2.0/authorize?
client_id=5f11e827-xxxx-4f1f-aa05-33a33f806aab
&response_type=code
&redirect_uri=https://jwt.ms/index
&response_mode=query
&scope=api://c848e37d-xxxx-4cd8-b9bf-0b2aa6927a82/access_as_user
&state=12345
- 使用授权码兑换访问令牌: