我有一个场景,userA在OneDrive for Business上与userB共享一个文件 . 他们都属于同一个Office365租户 .
有没有办法使用userB身份(OAuth访问令牌)以编程方式检索共享文件内容?我尝试过使用适用于userA的2.0 API语法,但是在尝试使用userB访问令牌执行此请求时遇到401错误,即使文件是与userB共享的 .
https://{tenantid}-my.sharepoint.com/_api/v2.0/drives/{driveId}/items/{itemId}/
或者可能有一种方法我可以使用Azure AD应用程序委派的权限代表其拥有driveId和itemId的所有者访问此文件?
2 回答
据我所知,此功能尚不支持 .
UserVoice上有此功能的请求,您可以投票 .
至于2016年3月,我能够以编程方式从OneDrive for Business检索共享文件内容的唯一方法是:
使用FullControl权限为整个租户创建SharePoint Provider托管插件
在https:// -my.sharepoint.com/_layouts/15/AppRegNew.aspx下注册应用程序
在SharePoint Online上创建应用程序目录并将应用程序发布到目录
在租户中的至少一个SharePoint网站集上安装应用程序
使用ClientSecret和ClientId执行以下代码http://blogs.msdn.com/b/vesku/archive/2015/01/05/customizing-onedrive-for-business-sites-with-app-model.aspx
Uri url = new Uri("https://{tenantid}-my.sharepoint.com/personal/{user}"); string realm = TokenHelper.GetRealmFromTargetUrl(url); var token = TokenHelper.GetAppOnlyAccessToken(TokenHelper.SharePointPrincipal,url.Authority, realm).AccessToken;
https://{tenantid}-my.sharepoint.com/_api/v2.0/drives/{driveId}/items/{itemId}/