0

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?

5
  • what have you tried so far ? the question needs sufficient code for a minimal reproducible example Commented Apr 14, 2024 at 11:21
  • aside from the above. you will need permissions (from the Admin) or nothing will work... Commented Apr 14, 2024 at 11:22
  • I think adding code doesn't improve anything. I tried the usual app_principal = { 'client_id': client_id, 'client_secret': secret_id, } ... 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? Commented Apr 15, 2024 at 5:57
  • This is either an password Admin question, in which case you need to speak to the admin, or a Coding question. It seems to be the former... Commented Apr 15, 2024 at 7:31
  • There is no need to update, since it still is not working. I do not understand, why I have such big problems connecting to SharePoint. Every delegated method works fine with OneDrive, but I do not get anything to authenticate to SharePoint except putting my username and password in a Python script... Commented Apr 24, 2024 at 12:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.