Azure active directory 如何从Ibiza扩展调用AAD图

Azure active directory 如何从Ibiza扩展调用AAD图,azure-active-directory,azure-ad-graph-api,Azure Active Directory,Azure Ad Graph Api,我试图调用AAD Graph,但出现了一个错误。 以下是我打电话的方式: MsPortalFx.Base.Net.ajax({ uri: `https://graph.windows.net/<id>/servicePrincipals/<id>?api-version=1.6-internal`, type: "GET", dataType: "json", cach

我试图调用AAD Graph,但出现了一个错误。 以下是我打电话的方式:

MsPortalFx.Base.Net.ajax({
        uri: `https://graph.windows.net/<id>/servicePrincipals/<id>?api-version=1.6-internal`,
        type: "GET",
        dataType: "json",
        cache: false,
        traditional: true,
        contentType: "application/json",
        setAuthorizationHeader: true,
    })
MsPortalFx.Base.Net.ajax({
uri:`https://graph.windows.net//servicePrincipals/?api-版本=1.6-内部`,
键入:“获取”,
数据类型:“json”,
cache:false,
传统的:是的,
contentType:“应用程序/json”,
setAuthorizationHeader:true,
})
我可以看到授权标头中提供了承载令牌,但我得到的错误如下:

HTTP/1.1 401 Unauthorized
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json;odata=minimalmetadata;streaming=true;charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.5
ocp-aad-diagnostics-server-name: <name>
request-id: <request-id>
client-request-id: <client-request-id>
x-ms-dirapi-data-contract-version: 1.6-internal
DataServiceVersion: 3.0;
Strict-Transport-Security: max-age=31536000; includeSubDomains
Access-Control-Allow-Origin: *
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Duration: 519919
X-Powered-By: ASP.NET
Date: Mon, 23 Nov 2020 22:49:42 GMT
Content-Length: 212

{"odata.error":{"code":"Authentication_MissingOrMalformed","message":{"lang":"en","value":"Access Token missing or malformed."},"requestId":"<id>","date":"2020-11-23T22:49:42"}}
HTTP/1.1 401未经授权
缓存控制:没有缓存
Pragma:没有缓存
内容类型:application/json;odata=最小元数据;流=真;字符集=utf-8
过期:-1
服务器:Microsoft IIS/8.5
ocp aad诊断服务器名称:
请求id:
客户端请求id:
x-ms-dirapi-data-CONTACT-version:1.6-internal
数据服务版本:3.0;
严格的交通安全:最大年龄为31536000岁;包含子域
访问控制允许来源:*
X-AspNet-Version:4.0.30319
X-Powered-By:ASP.NET
持续时间:519919
X-Powered-By:ASP.NET
日期:2020年11月23日星期一22:49:42 GMT
内容长度:212
{“odata.error”:{“code”:“Authentication_MissingOrMalformed”,“message”:{“lang”:“en”,“value”:“Access Token missing或畸形”。},“requestId”:“date”:“2020-11-23T22:49:42”}

如果我需要提供任何其他信息,请告诉我。

正如Sruthi所说,错误信息身份验证错误格式表示访问资源与访问令牌的AUD不匹配

您需要按照以下步骤获取访问令牌:

POST https://login.microsoftonline.com/<Your-Tenant-ID>/oauth2/token

// request body:
grant_type=client_credentials
client_id=<Your Portal Application ID>
client_secret=<Your client secret>
resource=https://graph.windows.net    // used to call AAD Graph API

正如Sruthi所说,错误信息身份验证错误的形式表示访问资源与访问令牌的AUD不匹配

您需要按照以下步骤获取访问令牌:

POST https://login.microsoftonline.com/<Your-Tenant-ID>/oauth2/token

// request body:
grant_type=client_credentials
client_id=<Your Portal Application ID>
client_secret=<Your client secret>
resource=https://graph.windows.net    // used to call AAD Graph API

请在查看您的访问令牌。代码应该是
https://graph.windows.net
。错误信息身份验证\u MissingOrMalformed表示访问资源与访问令牌的AUD不匹配。您需要在获取访问令牌期间将资源更改为。另外,请共享错误消息的相关id和时间戳。明白了。正在尝试此更改。谢谢请检查您的访问令牌。代码应该是
https://graph.windows.net
。错误信息身份验证\u MissingOrMalformed表示访问资源与访问令牌的AUD不匹配。您需要在获取访问令牌期间将资源更改为。另外,请共享错误消息的相关id和时间戳。明白了。试试这个变化。谢谢