我有这段 python 代码,它在我的计算机上完美运行,但当我在带有 Amazon Linux 的 EC2 上运行它时,它会卡在这个函数中。检查了所有网络和防火墙规则,一切正常。事实上,如果我从我的 PC 获取令牌并尝试通过 cURL 直接访问共享点(无需身份验证),它实际上可以工作。我缺少什么?
certfile = 'cert.pem'
thumbprint = 'XXX'
tenantID = 'XXX-XXX-XXX-XXX-XXX'
clientID = 'XXX-XXX-XXX-XXX-XXX'
scope = ['https://xxx.sharepoint.com/.default']
authority = f"https://login.microsoftonline.com/{tenantID}"
def msal_certificate_auth(clientID, scope, authority, thumbprint, certfile):
app = msal.ConfidentialClientApplication(clientID, authority=authority,
client_credential={"thumbprint": thumbprint, "private_key": open(certfile).read()},
azure_region=None )
result = app.acquire_token_for_client(scopes=scope)
return result
它正好挂在ConfidentialClientApplication
但我不知道如何更深入地调试。
文档结束https://msal-python.readthedocs.io/en/latest/ https://msal-python.readthedocs.io/en/latest/
如果位于防火墙后面,请检查代理是否按预期设置。我正在使用以下,但它永远卡住了。
msal.PublicClientApplication(config["client_id"], authority=config["authority"], validate_authority=False, verify=False)
代理修复成功了。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)