OneDrive API Python SDK-指向login.live.com而非mydomain.sharepoint.com [英] OneDrive API Python SDK - points to login.live.com not mydomain.sharepoint.com

查看:101
本文介绍了OneDrive API Python SDK-指向login.live.com而非mydomain.sharepoint.com的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用OneDrive API Python SDK 将文件上传到Office 365 E3帐户SharePoint文件夹.

I am trying to use the OneDrive API Python SDK to upload files to an Office 365 E3 account SharePoint folder.

如针对OneDrive for business/SharePoint文件所述,我正在使用Office 365 E3帐户中包含的Azure AD进行身份验证,并已在

As described for OneDrive for business / SharePoint files I am using Azure AD that is included in my Office 365 E3 account for auth and have created a native client application app in Azure AD management.

我希望我需要将身份验证指向Office 365:

I would expect that I need to point auth to Office 365:

mydomain.sharepoint.com

但是,似乎OneDrive API Python SDK(auth_provider.py)将auth指向:

However, it appears the OneDrive API Python SDK (auth_provider.py) points auth to:

AUTH_SERVER_URL = "https://login.live.com/oauth20_authorize.srf"
AUTH_TOKEN_URL = "https://login.live.com/oauth20_token.srf"

Github问题讨论表明OneDrive API Business仍处于测试阶段但是只需将基本URL更改为mydomain.sharepoint.com URL,就可以将SDK用于OneDrive API Business,例如:

This Github issue discussion indicates OneDrive API Business is still in beta but just changing base urls to mydomain.sharepoint.com urls is all that is needed to use SDK for OneDrive API Business eg:

AUTH_SERVER_URL = "https://mydomain.sharepoint.com/oauth20_authorize.srf"
AUTH_TOKEN_URL = "https://mydomain.sharepoint.com/oauth20_token.srf"

这正确吗?

进行编辑以确保也解决了其他相关问题:

Edited to ensure related additional questions are addressed too:

除了在OneDrive API Python SDK中需要修改以用于OneDrive for Business/Sharepoint的身份验证URL之外,还有其他内容吗?

Is there anything else other than the auth urls that needs to be modified in the OneDrive API Python SDK to be used for OneDrive for Business / Sharepoint?

Github自述文件包含用于身份验证的示例代码,该代码需要client_secret待识别.

The Github README includes sample code for authentication which requires client_secret and scopes to be identified.

但是,Azure Active Directory应用程序的创建过程包括范围标识,本机客户端应用程序不需要client_secret.

However the Azure Active Directory app creation process includes scope identification, and native client app doesn't require client_secret.

对于我的本机客户端应用授权,我在示例代码中将client_secretscopes留为空白,例如:

For my native client app authorization, I have just left client_secret and scopes blank in the sample code eg:

client_secret = ""
client = onedrivesdk.get_default_client(client_id='xxxxxetc', 
                                            scopes=[])

推荐答案

OneDrive for Business的身份验证由AAD处理,这意味着您需要指向AAD OAuth 2端点,即:

Auth for OneDrive for Business is handled by AAD, which means you need to point to the AAD OAuth 2 end points, which are:

AUTH_SERVER_URL = "https://login.microsoftonline.com/common/oauth2/authorize"
AUTH_TOKEN_URL = "https://login.microsoftonline.com/common/oauth2/token"

这大致记录在这里, https://dev.onedrive.com/auth/aad_oauth. htm ,尽管由于它描述的是身份验证流程,但如果您只是在寻找要与SDK一起使用的两个URL,则细节会隐藏起来.

This is roughly documented here, https://dev.onedrive.com/auth/aad_oauth.htm, although since that is describing the authentication flow the details are a bit hidden if you were just looking for the two URLs to use with the SDK.

这篇关于OneDrive API Python SDK-指向login.live.com而非mydomain.sharepoint.com的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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