Can I upload a file to the Microsoft SharePoint General Documents Library using the Python OneDrive SDK ?
This documentation says that it should be (in the first sentence), but I cannot do this work.
I can authenticate (using Azure AD) and upload it to the OneDrive folder, but when I try to upload it to the SharePoint folder, I keep getting this error
Type Exception Microsoft.IdentityModel.Tokens. AudienceUriValidationFailedException "was selected.
The code I use returns an object with an error:
(...authentication...) client = onedrivesdk.OneDriveClient('https://{tenant}.sharepoint.com/{site}/_api/v2.0/', auth, http) client.item(path='/drive/special/documents').children['test.xlsx'].upload('test.xlsx')

I can successfully download to https://{tenant}-my.sharepoint.com/_api/v2.0/ (note the -my "after {tenant} ) with the following code:
client = onedrivesdk.OneDriveClient('https://{tenant}-my.sharepoint.com/_api/v2.0/', auth, http) returned_item = client.item(drive='me', id='root').children['test.xlsx'].upload('test.xlsx')
How can I upload the same file to a SharePoint site?
(Answers to similar questions ( 1 , 2 , 3 , 4 ) when stack overflows are either too vague or suggest using a different API. My question is whether the OneDrive Python SDK can be used, and if so, how to do it.)
Refresh . Here is my complete code and conclusion. (Sensitive input has been replaced by similarly formatted gibberish.)
import re import onedrivesdk from onedrivesdk.helpers.resource_discovery import ResourceDiscoveryRequest
Output:
Exception of type 'Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException' was thrown. https://{tenant}-my.sharepoint.com/personal/user_domain_net/_layouts/15/WopiFrame.aspx?sourcedoc=%1ABCDE2345-67F8-9012-3G45-6H78IJKL9M01%2N&file=test.xlsx&action=default