我已经成功编写了一个可以访问下游API的API(使用v1 ADAL.NET),因此,我有一些代码。(客户端基于AutoRest)
此外,我已经成功运行了sample Microsoft Graph web app(但是,它已针对v2和MSAL进行了编码)
任何人都有访问下游API(例如Microsoft Graph)的API的示例。虽然我可以成功获取访问令牌,但是当我拨打电话时,我只会得到Microsoft.Graph.ServiceException
:
InvalidAuthenticationToken
Message: Access token validation failure.
示例访问令牌:
Header:
{
"alg": "RS256",
"typ": "JWT",
"x5t": "[removed]",
"kid": "[removed]"
}
Payload:
{
"aud": "https://graph.windows.net",
"iss": "https://sts.windows.net/[removed]/",
"iat": "1533754778",
"nbf": "1533754778",
"exp": "1533758925",
"acr": "1",
"aio": "[removed]",
"amr": "wia",
"appid": "[removed]",
"appidacr": "1",
"e_exp": "263047",
"family_name": "My Last Name",
"given_name": "My Name",
"ipaddr": "[removed]",
"name": "My Name My Last Name",
"oid": "[removed]-7593-4755-1234-bbbb1234aaaa",
"onprem_sid": "[removed]",
"puid": "[removed]",
"scp": "Directory.Read.All Mail.Send User.Read",
"sub": "[removed]",
"tenant_region_scope": "NA",
"tid": "[removed]",
"unique_name": "me@[removed].com",
"upn": "me@[removed].com",
"uti": "[removed]",
"ver": "1.0"
}
也许是this?正在下载...
我使用了错误的资源uri。有关详细信息,请参见下面的答案
答案 0 :(得分:0)
好的,我了解到的与Microsoft Graph API交互的关键知识:
GraphServiceClient
客户端的示例,但使用MSAL违反了v2。https://graph.windows.net
,但实际上只是:https://graph.microsoft.com