gpt4 book ai didi

Azure AD Python - 意外的轮询状态 invalid_client 错误

转载 作者:行者123 更新时间:2023-12-04 10:28:19 31 4
gpt4 key购买 nike

    store_token = context.acquire_token_with_device_code(resource_uri, code, client_id)
File "/Users/jyao/Desktop/azureblobtest/lib/python3.7/site-packages/adal/authentication_context.py", line 273, in acquire_token_with_device_code
return self._acquire_token(token_func)
File "/Users/jyao/Desktop/azureblobtest/lib/python3.7/site-packages/adal/authentication_context.py", line 109, in _acquire_token
return token_func(self)
File "/Users/jyao/Desktop/azureblobtest/lib/python3.7/site-packages/adal/authentication_context.py", line 266, in token_func
token = token_request.get_token_with_device_code(user_code_info)
File "/Users/jyao/Desktop/azureblobtest/lib/python3.7/site-packages/adal/token_request.py", line 398, in get_token_with_device_code
token = client.get_token_with_polling(oauth_parameters, interval, expires_in)
File "/Users/jyao/Desktop/azureblobtest/lib/python3.7/site-packages/adal/oauth2_client.py", line 345, in get_token_with_polling
wire_response)
adal.adal_error.AdalError: Unexpected polling state invalid_client

输入设备代码并成功登录后如何消除此错误。

步骤:

  1. 从 python 交互式提示符中运行此代码 [1](所有模块均已加载)。地点:
authority_url = 'https://login.microsoftonline.com/my_tenant_id'
resource_uri = "https://storage.azure.com/"
context = adal.AuthenticationContext(authority_uri)
code = context.acquire_user_code(resource_uri, client_id)
print(code['message'])
store_token = context.acquire_token_with_device_code(resource_uri, code, client_id)
credentials = AADTokenCredentials(store_token, client_id)

2.打开网址https://microsoft.com/devicelogin在浏览器中。

3.输入代码E8B2DVT67

4.确认应用名称,正确。

5.使用用户的凭据进行身份验证。

6.在浏览器中收到一条消息,显示“您已登录设备上的 TEST-APP 应用程序。您现在可以关闭此窗口。”

7.在python交互式提示符中获取我上一条消息中显示的错误。

我使用 native 应用程序并更新 list 并设置“allowPublicClient”:true 权限。

最佳答案

您的代码运行良好。

如果我们设置allowPublicClient:false,我们会遇到这个错误。

enter image description here

将allowPublicClient更新为true后,它将起作用。 注意:配置生效会有一些延迟

enter image description here

关于Azure AD Python - 意外的轮询状态 invalid_client 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60534963/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com