代码之家  ›  专栏  ›  技术社区  ›  Venkatesh T

无法进行身份验证-AADSTS50059:在请求中或任何提供的凭据中都找不到租户标识信息

  •  0
  • Venkatesh T  · 技术社区  · 2 年前

    一直在尝试访问SharePoint列表,并使用Python将数据下载为CSV作为用例。一旦我们到达身份验证步骤,我们就会得到错误

    “('针对Office 365进行身份验证时出错。来自Office 365的错误:“, 'AADSTS50059:在 请求或任何提供的凭据暗示。’)“

    
    from config import config
    
    from shareplum import Site 
    from shareplum import Office365
    from shareplum.site import Version
    from requests_ntlm import HttpNtlmAuth
    
    from office365.runtime.auth.authentication_context import AuthenticationContext
    from office365.sharepoint.client_context import ClientContext
    
    base_path = config.config['sp_base_path']
    username = config.config['sp_user']
    password = config.config['sp_password']
    
    
    ##Approach 1
    # cred = HttpNtlmAuth('myusername@domain.com', 'Password')
    # site = Site('https://xxxxxx.sharepoint.com/logs/Lists/Logs%20Entries/All%20Items.aspx', auth=cred)
    
    
    ##Approach 2
    # authcookie = Office365(base_path, username=username, password=password).GetCookies()
    # site = Site('https://xxxxxx.sharepoint.com/logs/Lists' ,version=Version.v365, authcookie=authcookie)
    
    

    方法1和方法2都抛出相同的错误。

    0 回复  |  直到 2 年前
        1
  •  0
  •   ChengFeng - MSFT    2 年前

    根据您提供的错误消息,可能是身份验证过程无法根据提供的凭据识别SharePoint租户。

    也许您可以尝试使用“shareplum”库提供的“Office365”身份验证方法,而不是使用“requests_ntlm”库进行身份验证。

    https://shareplum.readthedocs.io/en/latest/tutorial.html#:~:text=The%20Office365%20class%20grabs%20a%20login%20token%20from,site%20in%20Office365%20and%20add%20Https%3A%2F%2F%20at%20start.