我已添加scope到 Azure 门户 上“公开 API”,引用 Microsoft document并授予API permission到那个范围。之后,我使用 postman 请求 token 它返回错误 AADSTS70011:提供的请求必须包含“范围”输入参数。为输入参数“范围”提供的值无效。
当我尝试像这样的范围时 {resource}/.default
工作正常。但是,我需要像 {resource}/access_as_user
我已经尝试过这个link ,但没有成功。
最佳答案
您使用了错误的身份验证流程,并且您已授予委派权限
。在这种情况下,您应该使用 auth code flow .
然后您可以将范围设置为: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
- 使用授权代码兑换访问 token :
关于azure - 请求范围为 "Expose an API” 的 token 时出错。 AADSTS70011 :The provided value for the input parameter 'scope' is not valid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66475384/