Office365-REST-Python-Client icon indicating copy to clipboard operation
Office365-REST-Python-Client copied to clipboard

How to connect to the 21Vianet (China) version of SharePoint with MFA enabled account ?

Open mengdahuang opened this issue 6 months ago • 1 comments

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!

mengdahuang avatar Jun 16 '25 05:06 mengdahuang

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)

vgrem avatar Jun 19 '25 17:06 vgrem

thanks a lot!

mengdahuang avatar Sep 28 '25 12:09 mengdahuang