Replies: 1 comment
-
First, the scopes should have the sharepoint ones so the app can access the resources. Given that the authentication process goes as expected, to access the sharepoint document libraries check the methods for that inside the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, can anyone please help me with how to download a file from SharePoint? I've been going through this code all day and haven't figured anything out. I can access a specific file and its URL. However, when I try to download it using the code below, it gives me a 401 error even though the token is correct (I've tried both access and refresh tokens).
token handling
token_backend = FileSystemTokenBackend(token_path='my_folder', token_filename='my_token.txt')
scopes
scopes = ['https://graph.microsoft.com/.default', 'offline_access']
setup connection
credentials = (CLIENT_ID, SECRET_ID)
account = Account(credentials=credentials, auth_flow_type='authorization', scopes=scopes,
token_backend=token_backend, tenant_id=TENANT_ID)
conn = Connection(credentials)
connect to cloud
if not account.is_authenticated: # will check if there is a token and has not expired
account.authenticate()
else:
token_backend.check_token()
account.con.refresh_token()
And when I find the file, I wanted to download it like this:
access_token = token_backend.get_token()
And after that I get 401 ... Can anyone help me? Thank you guys
Beta Was this translation helpful? Give feedback.
All reactions