I am trying to get a Python script to upload files in an organization SharePoint. I am not the admin of said SharePoint, so I believe I can't add application permissions in Microsoft Graph. However, I also don't want to access the sharepoint with my e-mail and password in the Python script. The SharePoint folder I am trying to acces has a shared-link with a share-password. Those can be used by anyone to access the Sharepoint folder and edit files in it.
Now my question, what do I have to do, so that Python uses the shared link and password to upload files as guest?
I already tried logging in the SharePoint with my Organization-account, which worked perfectly. However, I never got a Python script working, where it was using client_id, etc. to authenticate. That's mainly why I don't want to use Microsoft Graph. If there is an easy fix, let me know.
I tried the usual
app_principal = {
'client_id': client_id,
'client_secret': secret_id,
}
context_auth = AuthenticationContext(url=site_url)
context_auth.acquire_token_for_app(client_id=app_principal['client_id'], client_secret=app_principal['client_secret'])
ctx = ClientContext(site_url, context_auth)
web = ctx.web
ctx.load(web)
ctx.execute_query()
print("Web site title: {0}".format(web.properties['Title']))
But I can't get authenticated, I also tried to get an access token, which I do, but I don't know how to use the access token to get authenticated. I believe I have said problems, because I don't have admin permissions. HOWEVER, in SharePoint I can create a shared-link with a shared-link-password. So why can't I just take both of those and upload files as guest from Python?