Graph API可访问oneDrive的业务项目/ffiles [英] Graph API to access oneDrive for business items/ffiles

查看:114
本文介绍了Graph API可访问oneDrive的业务项目/ffiles的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个文档管理应用程序,该用户应该能够访问oneDrive中的文件夹,有时可以处理同一文档/文件,编辑,复制应用程序中的文档以及将文档从应用程序上传到oneDrive.这意味着该文件夹应该对所有拥有权限的用户可用.我可以使用自己的个人帐户进行所有工作,例如,我使用此URL从FolderX中获取文件列表:"

I am working on a document management application, which users should be able to access folders in oneDrive, sometime work on the same document/file, edit, copy document in application and upload document from application to the oneDrive. And it means that folder should be available to all users who has right. I could make all works when I am using my own personal account, for example I am using this url for getting list of files from a folderX:"https://graph.microsoft.com/v1.0/me/drive/root:/folederX:/children"", all works perfectly. But When I am using business account it doesn't work. I authenticate via tenant ID and I get correct token, but after that I get 400 error. Now, I am really confused if what I want to achieve here is really possible via oneDrive for business or we should use sharepoint? Because apparently folderX is shared with me in oneDrive business account and it doesn't exist in my own oneDrive. Sorry if the question seems stupid but I am really confused here.

错误是:

这是错误的: {错误":{代码":"accessDenied",消息": 验证请求时出错.," innerError:{" request-id: "230e946c-d81a-4bf1-903e-26d92c5441db",日期":"2019-09-20T10:12:38" }}}

This is error: { "error": { "code": "accessDenied", "message": "There has been an error authenticating the request.", "innerError": { "request-id": "230e946c-d81a-4bf1-903e-26d92c5441db", "date": "2019-09-20T10:12:38" } } }

推荐答案

我了解您正在尝试使用个人Microsoft帐户来访问在客户的OneDrive for business中与您共享的文件.如有误会,请纠正我.

I understand that you are trying to use a personal Microsoft Account to access the files which have been shared with you in your customer's OneDrive for business. Correct me if there is any misunderstanding.

如果是这样,则需要使用

If so, you need to use the OAuth 2.0 code grant flow to get the access token.

首先,我假设您已将作为来宾用户的个人帐户添加到客户的Azure AD中.并且该文件已与您的个人帐户共享.并已在您客户的Azure AD中注册的应用程序中分配了正确的委派权限.

Firstly, I assume that you have added your personal account as a guest user to your customer's Azure AD. And the file has been shared with your personal account. And the correct delegated permissions have been assigned in the App registered in your customer's Azure AD.

您将收到这样的答复:

https://localhost/?code={code}&state=12345&session_state=54572324-6121-4add-85f8-22e3a815646b

请在此处复制代码"以备后用.

Please copy the "code" here for late use.

然后您可以发送访问令牌请求:

Then you can send a request for access token:

用客户的租户替换"jmaster.onmicrosoft.com"并修改其他值(包括 client_id client_secret redirect_uri 和<正文中的strong>代码).

Replace "jmaster.onmicrosoft.com" with your customer's tenant and modify the other values (including client_id, client_secret, redirect_uri and code) in Body.

获取访问令牌后,您可以发送访问共享文件的请求.

After getting the access token, you can send a request to access the shared files.

https://graph.microsoft.com/v1.0/users/{user id}/drive/root:/folederX:/children

请注意,这里的用户"是与您共享文件的人.

Please note that the "user" here is who shared the files with you.

这篇关于Graph API可访问oneDrive的业务项目/ffiles的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆