简体   繁体   English

Microsoft Graph api - 将文件写入我的 oneDrive

[英]Microsoft Graph api - write files to my oneDrive

I am writing a simple web app (Javascript) that includes a form, once the form has been submitted I want to save the data on my oneDrive as a new file.我正在编写一个简单的 web 应用程序(Javascript),其中包含一个表单,一旦提交了表单,我想将我的 oneDrive 上的数据保存为一个新文件。 That's all, But for some reason.就是这样,但出于某种原因。 I cannot accomplish this simple task.我无法完成这个简单的任务。

So I want to use oneDrive as my database.所以我想用 oneDrive 作为我的数据库。 but all I can find on the Microsoft Graph API are require a login popup which does not make sense here for me in this case cause the user have nothing to do with that.但我可以在 Microsoft Graph API 上找到的所有内容都需要一个登录弹出窗口,在这种情况下,这对我来说没有意义,因为用户与此无关。 just want the details will be submitted into my personal oneDrive.只是希望将详细信息提交到我的个人oneDrive。

I am using client_credentials flow to generate access token but I keep getting errors like 'Unable to retrieve tenant service info.'我正在使用 client_credentials 流来生成访问令牌,但我不断收到诸如“无法检索租户服务信息”之类的错误。 or 'Current authenticated context is not valid for this request' when I try to access the drive API.或当我尝试访问驱动器 API 时,“当前经过身份验证的上下文对此请求无效”。 I gave all the possible permissions to this app, I am using my personal free Microsoft account我已授予此应用程序所有可能的权限,我正在使用我的个人免费 Microsoft 帐户

so What am I missing here?所以我在这里错过了什么?

Another issue that I will be happy to know more about is that in my Azure app registration after I register this app and I go to the owner's tab I see this message - 'This app does not belong to any directory, so owners can't be added to it.'另一个我很乐意了解的问题是,在我注册此应用程序后,在我的 Azure 应用程序注册中,我将 go 到所有者的标签,我看到这条消息 - '此应用程序不属于任何目录,因此所有者不能被添加到它。 is that might be the problem?这可能是问题吗? how and do I even need to assign this app to a certain directory to use the API for my personal drive?如何以及我什至需要将此应用程序分配到某个目录才能将 API 用于我的个人驱动器?

Also when I am vising the Users section on my Azure portal I see this message - 'You don't have access to this data.'此外,当我查看 Azure 门户上的“用户”部分时,我看到了这条消息 - “您无权访问此数据。” How is that possible if I do not belong to any organization and I created this azure account??如果我不属于任何组织并且我创建了这个 azure 帐户,这怎么可能?

Thank you in advance, any information here will be helpful cause I am kinda lost.提前谢谢你,这里的任何信息都会有帮助,因为我有点迷路了。

I am using client_credentials flow to generate access token but I keep getting errors like 'Unable to retrieve tenant service info.'我正在使用 client_credentials 流来生成访问令牌,但我不断收到诸如“无法检索租户服务信息”之类的错误。 or 'Current authenticated context is not valid for this request' when I try to access the drive API.或当我尝试访问驱动器 API 时,“当前经过身份验证的上下文对此请求无效”。

For this you could use the Code Flow authentication为此,您可以使用代码流身份验证

在此处输入图像描述

In this, you will not be needing any tenant information - just the client credentials and access token to access the OneDrive API在此,您将不需要任何租户信息 - 只需客户端凭据和访问令牌即可访问 OneDrive API

https://docs.microsoft.com/en-us/onedrive/developer/rest-api/getting-started/msa-oauth?view=odsp-graph-online#code-flow https://docs.microsoft.com/en-us/onedrive/developer/rest-api/getting-started/msa-oauth?view=odsp-graph-online#code-flow

This app does not belong to any directory, so owners can't be added to it此应用不属于任何目录,因此无法添加所有者

If the app had been registered in the converged app portal - you are likely to encounter this.如果应用程序在融合应用程序门户中注册 - 您很可能会遇到这种情况。 You can you portal access this link and login with your personal account\live account.您可以通过门户访问此链接并使用您的个人帐户\真实帐户登录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM