I was trying to use that lib to connect with my SharePoint and download the file: https://github.com/vgrem/Office365-REST-Python-Client
I tried two approaches for auth:
- UserCredential
- ClientCredential
Code:
client_credentials = ClientCredential(f'{client_id}',f'{client_secret}')
ctx = ClientContext(url).with_credentials(client_credentials)
web = ctx.web.get_folder_by_server_relative_path("Shared Documents/Documents").expand(["Files", "Folders"]).get().execute_query()
#web = ctx.web
ctx.load(web)
ctx.execute_query()
print("Web title: {0}".format(web.properties['Title']))
I registered the app in Azure Portal with a tutorial from GitLab site but in the first example I have an error:
ValueError: Cannot get binary security token from https://login.microsoftonline.com/extSTS.srf
in client creds I have:
Forbidden 403 Error
I have already checked many possibilities:
- whether the user given is correct - email not login
- whether the password is correct - if I enter the wrong one there will be another error
- whether the SharePoint page is correct - if I enter a non-existent one, I get another error
- whether the query produced by the application is ok - if I type it directly in the browser while logged into SharePoint it returns the correct result.
How did I register the applications in Azure?
- I went into AD Azure, created a new application
- I generated a secret for it
- I added to API Permissions read access to SharePoint.
Is there anything else I should do? Did I leave something out? Maybe someone has encountered a similar problem?
I've run out of ideas - all links in google are already in purple.