Skip to content
Advertisement

Authenticate sharepoint with client_id and client_secret

Since basic user authentication is going away I need to update my auth process. I have tried multiple times but it doesn’t seem to work.

from office365.runtime.auth.authentication_context import AuthenticationContext
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.files.file import File

url = "https://test.sharepoint.com/sites/test001"
client_id = ""
client_secret = ""
    
context_auth = AuthenticationContext(url)
context_auth.acquire_token_for_app(client_id=client_id, client_secret=client_secret)
   
ctx = ClientContext(url, context_auth)
web = ctx.web
ctx.load(web)
ctx.execute_query()
print("Web site title: {0}".format(web.properties['Title']))

I have registered an app In azure with permissions.

enter image description here

I’m trying to use all the different values I can find here to set client_id and client_secret.

Any tips on how to get access by this method or another with the use of Office365-REST-Python-Client?

https://github.com/vgrem/Office365-REST-Python-Client

enter image description here

enter image description here

Advertisement

Answer

problem was solved with a new update in the library:

https://github.com/vgrem/Office365-REST-Python-Client/blob/master/examples/sharepoint/connect_with_client_certificate.py

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement