我想使用MSAL对Azure进行身份验证,我将其指定如下:
app = msal.ConfidentialClientApplication(
client_id=client_id,
client_credential=client_secret,
authority='https://login.microsoftonline.com/' + tenantname
)
result = app.acquire_token_for_client(scopes=scopes)它失败了,因为它找不到我可以访问的公司的租户名称,即使它是正确指定的。
Error description was: AADSTS700016: Application with identifier '12341234123somethingtest-fje2434823412341234123somethingtest-4322134-213413212341234123somethingtest' was not found in the directory '213412312341234123somethingtest-1234-3241'. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You may have sent your authentication request to the wrong tenant. Exception: Failed to obtain access token
我也尝试过来自AAD的租户名称和租户ID,并且总是得到相同的错误。有没有办法解决这个问题?(当我在自己的Azure上使用代码时,代码工作得很好。)
发布于 2021-04-13 12:29:11
你的错误已经解决了。这是由于您的client_id中缺少字符造成的。只需输入正确的client_id即可。
遇到类似的问题,可以在浏览器中运行管理员同意url调试:
https://login.microsoftonline.com/{tenant-id}/adminconsent?client_id={client-id}。
https://stackoverflow.com/questions/67073218
复制相似问题