如何在不创建应用程序的情况下使用 graph API 上传到 onedrive
How to upload to onedrive using graph API without creating an application
我有一个输出 .csv 文件的脚本。我想把这个上传到onedrive。
我没有权限创建应用程序。
我已经检查了 az cli 的 rest 选项,由于访问令牌没有正确的访问权限,我收到错误未找到。
Currently I am using python request module for uploading to onedrive.
I am using access token from graph explorer in the Authorization
header of API request. This way I am able to upload the file to
onedrive.
来自 az account get-access-token 输出的访问令牌导致 401 错误。
使用图形资源管理器的访问令牌时,它可以正确上传带有 201 状态代码的文件。
使用这种方式有安全隐患吗?
即使是cli脚本,我们需要在azure中注册应用程序吗?
谢谢
感谢您的提问。 Graph Explorer 的访问令牌有效,因为登录用户正在请求令牌。要上传文件,delegated permission Files.ReadWrite should be consented to, this does not require admin consent. While your workaround works, this is not the recommended way and actions taken by the script would be attributed to the user signed in to GE when the token was obtained. Since your script should run in the background, you will need to register an application on your tenant, give the application the Files.ReadWrite.All permission - 这需要管理员同意 - 然后请求访问令牌并上传文件。
让我知道这是否有帮助,如果您还有其他问题,
我有一个输出 .csv 文件的脚本。我想把这个上传到onedrive。
我没有权限创建应用程序。 我已经检查了 az cli 的 rest 选项,由于访问令牌没有正确的访问权限,我收到错误未找到。
Currently I am using python request module for uploading to onedrive. I am using access token from graph explorer in the Authorization header of API request. This way I am able to upload the file to onedrive.
来自 az account get-access-token 输出的访问令牌导致 401 错误。 使用图形资源管理器的访问令牌时,它可以正确上传带有 201 状态代码的文件。
使用这种方式有安全隐患吗? 即使是cli脚本,我们需要在azure中注册应用程序吗?
谢谢
感谢您的提问。 Graph Explorer 的访问令牌有效,因为登录用户正在请求令牌。要上传文件,delegated permission Files.ReadWrite should be consented to, this does not require admin consent. While your workaround works, this is not the recommended way and actions taken by the script would be attributed to the user signed in to GE when the token was obtained. Since your script should run in the background, you will need to register an application on your tenant, give the application the Files.ReadWrite.All permission - 这需要管理员同意 - 然后请求访问令牌并上传文件。
让我知道这是否有帮助,如果您还有其他问题,