Office365-REST-Python-Client icon indicating copy to clipboard operation
Office365-REST-Python-Client copied to clipboard

401 Client Error: Unauthorized

Open lastorder999 opened this issue 1 year ago • 0 comments

My program for uploading files to SharePoint was working normally until last week. Now, I see an error occurring during the upload process. I tested it using this code, and it’s giving me an error.

from office365.runtime.auth.client_credential import ClientCredential
from office365.sharepoint.client_context import ClientContext

client_id = "[client_id]"
client_secret = "[client_secret]
site_url = "https://example.sharepoint.com/site/ShareDoc"

client_credentials = ClientCredential(client_id, client_secret)
ctx = ClientContext(site_url).with_credentials(client_credentials)
web = ctx.web
ctx.load(web)
ctx.execute_query()

This is the error I received Screenshot 2024-10-11 154020

Screenshot 2024-10-11 154048

I followed this link for my client_id and client_secret https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs I don’t understand why this issue is happening because it was normal before.

lastorder999 avatar Oct 11 '24 09:10 lastorder999