Office365-REST-Python-Client
Office365-REST-Python-Client copied to clipboard
How to connect to the 21Vianet (China) version of SharePoint with MFA enabled account ?
Thank you to the author of this project!
I would like to ask, my O365 is Operated by 21Vianet under Chinese regulations. Currently, I am using the PowerShell command below to access SharePoint Online and retrieve metadata information for relevant files:
Connect-PnPOnline https://xxxx.sharepoint.cn/teams/xxx -UseWebLogin
## Get File's metainfo
$file = Get-PnPFile -Url "/teams/ITO/Shared%20Documents/123/Test.docx" -AsListItem
$file.FieldValues.MetaInfo
May I ask how to connect and retrieve metadata information for all files in a specified file or directory using this project?
Thank you!
Greetings!
Yes, this should be supported starting from version 2.6.0 (release notes: GitHub). Here's a minimal example:
from office365.azure_env import AzureEnvironment
from office365.sharepoint.client_context import ClientContext
ctx = ClientContext(
site_url,
environment=AzureEnvironment.China
).with_interactive(tenant_name_or_id, client_id)
file = ctx.web.get_file_by_server_relative_path(file_url)
thanks a lot!