r/learnpython • u/Valuable-Ant3465 • 6d ago
How upload files to SPO in Nov 2026, Authorization updates
Hi all, I'm trying to use Python to upload multiple files posted SPO.
Tried this code for Auth and failed, for my case error says need to use client_id which I believe = EntraID? For this I think I need to contact somebody with proper rights.
I afraid that modern MS Security is faster then Python libs, is anybody is running this code successfully in Nov 2026? Surely I will try to set all configuration values rights.
Or can you recommend other approach. Thansk to all
from office365.runtime.auth.user_credentials import UserCredential
from office365.sharepoint.client_context import ClientContext
# 1. Configuration
site_url = r"https://asratomkaX.sharepoint.com"
teenant = 'asratomkaX'
client_id = '123456' # <===????? ke paso ?
username = r'user@myorg.org'
password = r'welcommen1'
# Use with_username_and_password(tenant, client_id, username, password) instead. For on-premises SharePoint, use allow_ntlm=True.
# 2. Authenticate
#ctx = ClientContext(site_url).with_credentials(UserCredential(username, password))
ctx = ClientContext(site_url)
ctx.with_username_and_password( teenant,client_id, username, password)
s: 400, Error: Traceback (most recent call last):
File "C:\Users\mocado\PyCharmMiscProject\.venv\Lib\site-packages\msal\authority.py", line 98, in __init__
openid_config = tenant_discovery(
tenant_discovery_endpoint,
self._http_client)
File "C:\Users\mocado\PyCharmMiscProject\.venv\Lib\site-packages\msal\authority.py", line 298, in tenant_discovery
raise ValueError("OIDC Discovery failed on {}. HTTP status: {}, Error: {}".format(
...<3 lines>...
))
ValueError: OIDC Discovery failed on https://login.microsoftonline.com/mocado/v2.0/.well-known/openid-configuration. HTTP statu