Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sharepoint Azure Active Directory图形Api-用户_Sharepoint_Azure Active Directory_Csom_Azure Ad Graph Api_Bearer Token - Fatal编程技术网

Sharepoint Azure Active Directory图形Api-用户

Sharepoint Azure Active Directory图形Api-用户,sharepoint,azure-active-directory,csom,azure-ad-graph-api,bearer-token,Sharepoint,Azure Active Directory,Csom,Azure Ad Graph Api,Bearer Token,我正在尝试使用Graph API,我正在根据SharePoint站点作为资源URL进行身份验证。这是因为我正在使用C#CSOMAPI与sharepoint网站进行对话 当我尝试使用相同的承载令牌发出graph api请求时,它表示未经授权。我也给了移动应用程序Graph API的权限。这是否意味着我的资源uri需要不同,如果是的话,它应该是什么,因为它不清楚?我不知道如何找到它 我基本上希望在azure中为注册的应用程序授予sharepoint和graph api权限。当我获得令牌时,我希望能够

我正在尝试使用Graph API,我正在根据SharePoint站点作为资源URL进行身份验证。这是因为我正在使用C#CSOMAPI与sharepoint网站进行对话

当我尝试使用相同的承载令牌发出graph api请求时,它表示未经授权。我也给了移动应用程序Graph API的权限。这是否意味着我的资源uri需要不同,如果是的话,它应该是什么,因为它不清楚?我不知道如何找到它

我基本上希望在azure中为注册的应用程序授予sharepoint和graph api权限。当我获得令牌时,我希望能够将其用于这两种类型的请求

var client = new HttpClient();

client.DefaultRequestHeaders.Add("Accept", "application/json");
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "TOKEN_FROM_AUTHENTCIATION");

var result = client.GetAsync("https://graph.microsoft.com/v1.0/me/messages?$select=subject,from,receivedDateTime&$top=25&$orderby=receivedDateTime%20DESC").Result;
我的连接详细信息类似于以下内容:

<add key="ida:AADInstance" value="https://login.microsoftonline.com/{0}" />
<add key="ida:Tenant" value="mytenant.onmicrosoft.com" />
<add key="ida:ApplicationId" value="A GUID" />
<add key="ida:RedirectUri" value="http://AnyUri/" />
<add key="ida.ResourceUrl" value="https://mytenant.sharepoint.com/" />

我认为我的资源URL需要是一个图形api,但无法理解它应该是什么,我必须为我的域创建一个图形api实例吗

我使用fiddler使用令牌发出此请求,如下所示,但这是未经授权的401

GET https://graph.windows.net/22312560-20c8-0000-0000-0000000000/users/user@microsoft.com/$links/manager?api-version=1.6

Content-Type: text/json
Accept: application/json
Host: graph.windows.net
Content-Length: 0
Authorization: Bearer <THE_TOKEN>
GEThttps://graph.windows.net/22312560-20c8-0000-0000-0000000000/users/user@microsoft.com/$links/manager?api版本=1.6
内容类型:text/json
接受:application/json
主机:graph.windows.net
内容长度:0
授权:持票人

以下是确保应用程序按预期工作所需的步骤:

  • 确保您的应用程序注册具有进行API调用所需的作用域

  • 将资源设置为“”

  • 获取此资源的详细信息
  • 使用此新令牌调用Microsoft Graph API。您可以通过使用JWT解码器来检查一切是否正常

  • 嗨,Shawn,我已将ResourceId设置为,但当我尝试发出fiddler请求时,我仍然收到的令牌显示未验证,我将用fiddler示例更新我的问题,我可以尝试的简单图形请求是什么?请注意,Azure Active Directory图形API
    https://graph.windows.net/
    与Microsoft Graph API不同
    https://graph.microsoft.com/
    。如果您获得特定资源的令牌,则该令牌仅在调用该资源时有效。这里的错误似乎是使用MS Graph API的令牌调用AAD Graph API。请尝试拨打此电话:
    https://graph.microsoft.com/v1.0/me/
    Perfect,谢谢,太好了,现在您向我展示了这么简单的东西,非常感谢您是否可以再次验证sharepoint网站,然后使用相同的令牌获取graph api详细信息。目前,我正在获取指向此资源的sharepoint令牌,但我们不想登录两次,因为我们使用的是MFA身份验证?这里提出的问题