
Hi @cparkinson
You will need to check the steps in grant permission to the app. First register ID and secret in https://contoso.sharepoint.com/sites/sitetitle/_layouts/15/appregnew.aspx
After generated a client ID and secret, You need to go https://contoso.sharepoint.com/sites/sitetitle/_layouts/15/appinv.aspx grant permission to the app with following xml scope
<AppPermissionRequests AllowAppOnlyPolicy="true">
<AppPermissionRequest Scope="http://sharepoint/content/sitecollection" Right="FullControl" />
</AppPermissionRequests>
You can refer to the following document for more details
https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs
Then you can use the code to access sharepoint
"""
Example: SharePoint App-Only auth flow
https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs
"""
from examples import sample_site_url, sample_client_id, sample_client_secret
from office365.runtime.auth.client_credential import ClientCredential
from office365.sharepoint.client_context import ClientContext
ctx = ClientContext(sample_site_url).with_credentials(ClientCredential(sample_client_id, sample_client_secret))
target_web = ctx.web.get().execute_query()
print(target_web.url)
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.