I am trying to use the OneDrive API Python SDK to upload files to an Office 365 E3 account SharePoint folder.
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.
I would expect that I need to point auth to Office 365:
mydomain.sharepoint.com
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"
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"
Is this correct?
Edited to ensure related additional questions are addressed too:
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?
The Github README includes sample code for authentication which requires client_secret
and scopes
to be identified.
However the Azure Active Directory app creation process includes scope identification, and native client app doesn't require client_secret
.
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=[])
Auth for OneDrive for Business is handled by AAD, which means you need to point to the AAD OAuth 2 end points, which are:
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.
If you take a look at the
onedrivesdk_helpers
module, you'll see that it defaults toapi.onedrive.com
. I would recommend using the following code in place ofget_default_client
:Make sure to import those classes with
from onedrivesdk import HttpProvider, AuthProvider, OneDriveClient