How to authenticate sharepoint on 21vianet
I tried to authenticate my Sharepoint on 21vianet with client secret, but it reported '401 Client Error: Unauthorized for url: https://graph.microsoft.com/v1.0/web/getFileByServerRelativePath%28DecodedUrl%3D%27https://galab.sharepoint.cn/:x:/g/EdLtDQIxUHxLj0FuemeleMsBaczbg7-bNKcqyDIyHR5utA%3Fe%3DO04gLy%27%29/%5C%24value'
I have identify the authority url and acquire token url by using the url of "https://login.chinacloudapi.cn/{0}".format(test_tenant) and "https://microsoftgraph.chinacloudapi.cn/.default" according to https://learn.microsoft.com/en-us/previous-versions/office/office-365-api/api/o365-china-endpoints
Please see my screenshot as below
Could you help me where is my code's problem?
Greetings,
assuming file url represents a sharing link, consider to utilize ClientContext instead of GraphClient client and get_file_by_guest_url method to return a file:
ctx = ClientContext(test_site_url).with_access_token(acquire_token)
file = ctx.web.get_file_by_guest_url(file_url).execute_query()
In the acquire_token method, the scope needs to be adjusted accordingly to:
scopes = ["https://galab.sharepoint.cn/.default"]