user16645952
user16645952

Reputation:

Move sharepoint files using office365 Rest API

I'm a bit confused by the documentation, this library is totally new to me. Any tips to troubleshoot this authentication error?

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


        site_url = 'https://example.sharepoint.com'

        user = '[email protected]'
        passwd = '@revossw#'

        old_file_url = '/sites/example/Shared Documents/Files/A Cidadela - A. J. Cronin.mobi'
        new_file_url = '/sites/example/Shared Documents/New'

        # Authenticate
        ctx_auth = AuthenticationContext(site_url)
        if ctx_auth.acquire_token_for_user(user, passwd):
            ctx = ClientContext(site_url, ctx_auth)

            # Get the source file
            source_file = ctx.web.get_file_by_server_relative_url(old_file_url )
            ctx.load(source_file)
            ctx.execute_query()

            # Move the file to a new location
            source_file.moveto(new_relative_url=new_file_url, flag=1)
            ctx.execute_query()

File "C:\Users\krzgv\anaconda3\Lib\site-packages\office365\runtime\auth\providers\saml_token_provider.py", line 262, in _process_service_token_response raise ValueError(self.error) ValueError: Cannot get binary security token for from https://login.microsoftonline.com/extSTS.srf

old_file_url = 'Shared Documents/Files/A Cidadela - A. J. Cronin.mobi'

Upvotes: 0

Views: 115

Answers (0)

Related Questions