You need to enable JavaScript to run this app. 使用AuthenticationContext认证SharePoint连接失败,执行execute_query时遇AADSTS900023错误的排查求助
优惠活动
大模型
产品
解决方案
定价
更多

使用AuthenticationContext认证SharePoint连接失败,执行execute_query时遇AADSTS900023错误的排查求助

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.13 19:47:59