Como usar a API REST do sharepoint para baixar os sites para o computador via script Python com a autenticação 2 pontos ?

Felipe Matheus 0 Reputation points
2023-12-29T15:35:38.89+00:00

Como usar a API REST do sharepoint para baixar os sites para o computador via script Python com a autenticação 2 pontos ?

Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft Security | Microsoft Authenticator
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,476 Reputation points Microsoft External Staff
    2024-01-01T01:57:44.1733333+00:00

    Hi @Felipe Matheus,

    You could grant access to app only and use client id and client secret to connect sharepoint

    from office365.sharepoint.client_context import ClientContext
    from tests import test_client_id, test_client_secret, test_site_url
    
    ctx = ClientContext(test_site_url).with_client_credentials(
        test_client_id, test_client_secret
    )
    target_web = ctx.web.get().execute_query()
    print(target_web.url)
    
    
    

    Here is the document for more details

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


    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.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.