![](/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.