【发布时间】:2015-03-20 14:15:03
【问题描述】:
我正在开发一个使用 Office 365 身份验证的 Web 应用程序。
我需要访问用户的 SharePoint 文件。该应用程序是多租户应用程序,这意味着我不知道 Sharepoint URL,但我可以使用 Microsoft Discover API 来发现当前用户的 Sharepoint URL。
我想使用Microsoft.Sharepoint.Client 库访问共享点文件。考虑以下代码:
ClientContext context = new ClientContext("https://discoveredserver.sharepoint.com");
// The SharePoint web at the URL.
Web web = context.Web;
// We want to retrieve the web's properties.
context.Load(web);
我收到 403 未授权,因为客户端对象没有凭据。问题是我无法在运行时设置凭据,因为我没有它,我唯一拥有的是 Bearer 令牌,它允许使用 HTTP 标头授权连接到 Sharepoint API。
有什么方法可以在 Sharepoint 客户端中设置 Bearer 令牌来调用 Sharepoint Web Services?
【问题讨论】:
标签: sharepoint office365