简体   繁体   English

OneDrive-如何使用Rest API访问我的企业帐户中的用户文件?

[英]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.

相关问题 使用文件REST API在OneDrive for Business上创建包含内容的文件 - Create a file with content on OneDrive for Business with Files REST API 使用REST API将文件上传到Onedrive - Uploading files to Onedrive using REST API 在.NET应用程序以外的其他方面通过REST api访问Onedrive for Business Files? - Accessing Onedrive For Business Files via REST api in something other than a .NET application? 是否可以使用REST API在OneDrive for Business上的子目录中创建文件? - Can I create a file to subdirectory on OneDrive for Business with REST API? OneDrive API(REST),在不同的OneDrive帐户之间复制文件/文件夹 - OneDrive API (REST), Copy Files/Folder between different OneDrive Accounts 如何使用REST从OneDrive for Business获得项目的权限? - How can I get permissions for an item from OneDrive for Business using REST? OneDrive REST API-上传-文件> 4GB - OneDrive REST API - Upload - Files > 4GB 在Azure中使用基于角色的授权时,如何允许服务帐户访问REST API? - How can I allow a service account to access my REST API when using Roles-based Authorization in Azure? 使用 REST API 从 OneDrive 下载文件 - Download File from OneDrive using REST API 使用 REST API 将文件上传到 onedrive - upload file to onedrive using REST API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM