![](/img/trans.png)
[英]After adding a scope to a OpenID Connect Identity Provider (an Azure AD tenant), the new scope is not returned in the idp_access_token
[英]Scope is not being added to Access Token returned from Azure Ad
概述
我们有一个 Azure AD 安全 API 生活在 Azure 作为 web 应用程序。 我们需要能够:
问题
问题是,当我们从 Azure AD 请求令牌时,scope 未在我们的令牌声明中设置,导致 API 拒绝令牌。
此请求返回具有以下声明的访问令牌:
{
"aud": "<our api client id>",
"iss": "https://login.microsoftonline.com/<tenantId>/v2.0",
"iat": 1644421512,
"nbf": 1644421512,
"exp": 1644425412,
"aio": "<value>",
"azp": "<scheduled job client id>",
"azpacr": "1",
"oid": "<guid>",
"rh": "<value>",
"sub": "<guid>",
"tid": "<guid>",
"uti": "<value>",
"ver": "2.0"
}
正如您所见, scp
(范围)未包含在令牌声明中,即使我们将其包含在请求中也是如此。
如果我们使用此令牌向我们的 API 发出请求,我们会收到以下错误:
System.UnauthorizedAccessException: IDW10201: Neither scope or roles claim was found in the bearer token.
任何关于我们如何从 Azure AD 获得访问令牌并具有适当范围/权限以调用我们的 API 的任何帮助,将不胜感激。
笔记
我们预定作业的 Azure AD 应用程序注册将请求令牌,然后点击我们的 API,确实具有委托 API 权限access_as_user
,您可以看到我将其包含在令牌请求的 scope 中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.