[英]OneDrive - how to access files of users in my Business account using the Rest API?
I have a corporate account with OneDrive users. 我有一个OneDrive用户的公司帐户。 I need to be able to access certain files within those users OneDrive accounts within my organization.
我需要能够访问我组织内这些用户的OneDrive帐户中的某些文件。 For migration and backup purposes.
用于迁移和备份。
We do something similar for our Google drive and Box.com accounts where we use JWT authentication to provide a Simulate-User
header which makes it so we can access all our users files within our organization if needed. 我们对Google云端硬盘和Box.com帐户进行了类似的操作,在这些帐户中,我们使用JWT身份验证提供了
Simulate-User
标头,因此可以在需要时访问组织中的所有用户文件。 As if we were administrators on a shared drive or something. 好像我们是共享驱动器之类的管理员一样。
Is there a Rest API example of OneDrive JWT service account or something equivalent? 有OneDrive JWT服务帐户的Rest API示例或等效的示例吗?
What you need is the client credentials grant flow. 您需要的是客户端凭据授予流程。 This will allow you to obtain an app-only token and make service calls without a user identity.
这将使您获得仅应用程序的令牌并在没有用户身份的情况下进行服务调用。 You can read more about it here:
你可以在这里读更多关于它的内容:
https://developer.microsoft.com/en-us/graph/docs/concepts/auth_v2_service https://developer.microsoft.com/zh-cn/graph/docs/concepts/auth_v2_service
The scopes you will need to request are Files.Read.All, and the consent will need to be granted by the tenant admin. 您需要请求的范围是Files.Read.All,并且需要由租户管理员授予同意。 You can read more about the permissions required for your scenario here (application permissions is what you are looking for):
您可以在此处阅读有关您的方案所需的权限的更多信息(您正在寻找应用程序权限):
https://developer.microsoft.com/en-us/graph/docs/concepts/permissions_reference#files-permissions https://developer.microsoft.com/zh-CN/graph/docs/concepts/permissions_reference#files-permissions
Here is a link to a sample Microsoft Graph project which uses app only tokens(we recommend using Microsoft Graph): 这是一个指向示例Microsoft Graph项目的链接,该项目仅使用应用程序令牌(建议使用Microsoft Graph):
https://github.com/microsoftgraph/nodejs-apponlytoken-rest-sample https://github.com/microsoftgraph/nodejs-apponlytoken-rest-sample
Or if you are planning on calling directly into the OneDrive API(not recommended), then you can use the following sample: 或者,如果您打算直接调用OneDrive API(不建议使用),则可以使用以下示例:
https://github.com/rgregg/onedrive-app-delegate-sample https://github.com/rgregg/onedrive-app-delegate-sample
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.