【发布时间】:2016-10-19 03:46:08
【问题描述】:
我正在尝试使用 Microsoft graph 访问 SharePoint 网站,但我在响应消息中收到“Un Authorized”。
这是我试图访问以获取 SP 站点的内容:https://graph.microsoft.com/beta/sharePoint/sites
查询在图形资源管理器中有效,但不能通过我的客户端代码。
注意:该应用具有 SharePoint Online 和 Microsoft Graph 的完全委派权限。
我尝试从我的应用程序调用其他 SharePoint 资源,但仍然收到未经授权的错误消息。
代码:
using (var client = new HttpClient())
{
using (var request = new HttpRequestMessage(HttpMethod.Get, "https://graph.microsoft.com/beta/sharePoint/sites"))
{
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
using (HttpResponseMessage response = await client.GetAsync("https://graph.microsoft.com/beta/sharePoint/sites"))
{
if (response.IsSuccessStatusCode)
{
msgResponse.Status = SendMessageStatusEnum.Sent;
msgResponse.StatusMessage = await response.Content.ReadAsStringAsync();
}
else
{
msgResponse.Status = SendMessageStatusEnum.Fail;
msgResponse.StatusMessage = response.ReasonPhrase;
}
}
}
【问题讨论】:
标签: office365 office365api microsoft-graph-api office365-restapi