使用AuthenticationContext认证SharePoint连接失败,执行execute_query时遇AADSTS900023错误的排查求助
大家好,我在Matillion的PythonScript组件里运行下面这段Python代码,尝试通过AuthenticationContext认证连接SharePoint,但碰到了棘手的问题:
from office365.sharepoint.client_context import ClientContext from office365.runtime.auth.authentication_context import AuthenticationContext authority_url = “https://login.microsoftonline.us/<tenant_id>” site_url = “https://mysite.sharepoint.us/sites/myfolder” auth_ctx = AuthenticationContext(authority_url) if auth_ctx.acquire_token_for_app(client_id, client_secret): ctx = ClientContext(site_url, auth_ctx) web = ctx.web ctx.load(web) ctx.execute_query() print("Web Title:", web.properties["Title"]) else: raise ValueError(“Failed to acquire token for the given client credentials.”)
代码执行到ctx.execute_query()这一行直接报错,错误信息是这样的:
ValueError: {"error":"invalid_request","error_description":"AADSTS900023: Specified tenant identifier 'none' is neither a valid DNS name, nor a valid external domain.
这个错误提示说租户标识符是'none',但我明明已经把authority_url里的<tenant_id>替换成了实际的租户ID,可错误里还是显示'none',而且整个提示也没说清楚到底哪出了问题。有没有大佬能给点排查的方向,帮我找出问题根源呀?
备注:内容来源于stack exchange,提问作者David Makovoz
相关产品推荐
相关产品推荐

