英文:
Is there any way to get the permissions from a shared file - OneDrive?
问题
如何使用GraphAPI获取OneDrive上与我共享的文件的权限详细信息?
我尝试了以下代码,但权限值为null。
IDriveSharedWithMeCollectionPage driveItems = await graphClient.Me.Drive.SharedWithMe().Request(requestOptions)
.WithUserAccount(ClaimsPrincipal.Current.ToGraphUserAccount())
.GetAsync();
是否有一种方法可以使用GraphAPI从我的共享文件中获取权限详细信息,如读/写或只读?
权限显示在OneDrive的管理访问选项中,但如何通过API获取详细信息?
是否可能通过使用这样的API获取这些数据?
英文:
How do I get the permission details of files shared with me on OneDrive using GraphAPI?
I tried the following code but the permission values are null.
IDriveSharedWithMeCollectionPage driveItems = await graphClient.Me.Drive.SharedWithMe().Request(requestOptions)
.WithUserAccount(ClaimsPrincipal.Current.ToGraphUserAccount())
.GetAsync();
Is there any way to get the permission details like read/write or readonly by using the GraphAPI from my shared Files?
The permissions are showing in the OneDrive at the Manage Access option but how do I get the details by using an API ?
Is it possible to get those data by using such an API?
答案1
得分: 1
我还没有尝试过,但我猜权限是针对驱动项目的,只有在获取驱动项目后才能获得它。您可以按以下方式获取共享项目:
GraphServiceClient graphClient = new GraphServiceClient(authProvider);
var sharedWithMe = await graphClient.Me.Drive
.SharedWithMe()
.Request()
.GetAsync();
然后:
GraphServiceClient graphClient = new GraphServiceClient(authProvider);
var permissions = await graphClient.Me.Drive.Items["{item-id}"].Permissions
.Request()
.GetAsync();
DriveItem的权限关系不能在获取DriveItem或DriveItems集合的调用中展开。您必须直接访问权限属性。
DriveItem的有效共享权限可以来自两个来源:
-
直接应用于DriveItem本身的共享权限。
-
继承自DriveItem祖先的共享权限。
附加参考:
希望能有所帮助。
英文:
I haven't tried it but i am guessing that permissions are specific to the drive item which you can get it after fetching it only.You can get shared item like below:
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var sharedWithMe = await graphClient.Me.Drive
.SharedWithMe()
.Request()
.GetAsync();
and then :
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var permissions = await graphClient.Me.Drive.Items["{item-id}"].Permissions
.Request()
.GetAsync();
The permissions relationship of DriveItem cannot be expanded as part of a call to get DriveItem or a collection of DriveItems. You must access the permissions property directly.
Effective sharing permissions of a DriveItem can come from two sources:
-
Sharing permissions applied directly on the DriveItem itself.
-
Sharing permissions inherited from the DriveItem's ancestors.
Additional reference:
Hope it helps.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论