Microsoft 团队 echo bot 示例不断失败并出现“access_token”错误

问题描述 投票:0回答:2

我遇到了非常一致的问题,因为它与我的团队机器人的 access_token 相关。我正在使用用 python 编写的“02.echo-bot”示例。

当我转到 Azure 门户 -> 应用程序注册 -> 我的应用程序 -> 证书和服务时,我拥有的唯一客户端密钥中的“值”与我的

APP_PASSWORD
文件中的
config.py
一致。我的
APP_ID
值也与我在“概述”页面上的应用程序(客户端)ID 的值一致。

我已经正确设置了 ngrok,将流量转发到由

app.py
启动的服务器,当我从机器人框架网页的“测试”选项卡发送消息时,我可以看到流量流动。

但是,每次我发送消息时,我都会看到以下错误:

root@test:~/teams-bot-test/botbuilder-samples/samples/python/02.echo-bot# python3 app.py 
/usr/local/lib/python3.10/dist-packages/botbuilder/schema/__init__.py:80: UserWarning: The Bot Framework Python SDK is being retired with final long-term support ending in November 2023, after which this repository will be archived. There will be no further feature development, with only critical security and bug fixes within this repository being undertaken. Existing bots built with this SDK will continue to function. For all new bot development we recommend that you adopt Power Virtual Agents.
  warn(
======== Running on http://localhost:3978 ========
(Press CTRL+C to quit)

 [on_turn_error] unhandled error: 'access_token'
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/botbuilder/core/bot_adapter.py", line 128, in run_pipeline
    return await self._middleware.receive_activity_with_status(
  File "/usr/local/lib/python3.10/dist-packages/botbuilder/core/middleware_set.py", line 69, in receive_activity_with_status
    return await self.receive_activity_internal(context, callback)
  File "/usr/local/lib/python3.10/dist-packages/botbuilder/core/middleware_set.py", line 79, in receive_activity_internal
    return await callback(context)
  File "/usr/local/lib/python3.10/dist-packages/botbuilder/core/activity_handler.py", line 70, in on_turn
    await self.on_message_activity(turn_context)
  File "/root/teams-bot-test/botbuilder-samples/samples/python/02.echo-bot/bots/echo_bot.py", line 17, in on_message_activity
    return await turn_context.send_activity(
  File "/usr/local/lib/python3.10/dist-packages/botbuilder/core/turn_context.py", line 174, in send_activity
    result = await self.send_activities([activity_or_text])
  File "/usr/local/lib/python3.10/dist-packages/botbuilder/core/turn_context.py", line 226, in send_activities
    return await self._emit(self._on_send_activities, output, logic())
  File "/usr/local/lib/python3.10/dist-packages/botbuilder/core/turn_context.py", line 304, in _emit
    return await logic
  File "/usr/local/lib/python3.10/dist-packages/botbuilder/core/turn_context.py", line 221, in logic
    responses = await self.adapter.send_activities(self, output)
  File "/usr/local/lib/python3.10/dist-packages/botbuilder/core/bot_framework_adapter.py", line 735, in send_activities
    raise error
  File "/usr/local/lib/python3.10/dist-packages/botbuilder/core/bot_framework_adapter.py", line 720, in send_activities
    response = await client.conversations.reply_to_activity(
  File "/usr/local/lib/python3.10/dist-packages/botframework/connector/aio/operations_async/_conversations_operations_async.py", line 524, in reply_to_activity
    response = await self._client.async_send(
  File "/usr/local/lib/python3.10/dist-packages/msrest/async_client.py", line 115, in async_send
    pipeline_response = await self.config.pipeline.run(request, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/msrest/pipeline/async_abc.py", line 159, in run
    return await first_node.send(pipeline_request, **kwargs)  # type: ignore
  File "/usr/local/lib/python3.10/dist-packages/msrest/pipeline/async_abc.py", line 79, in send
    response = await self.next.send(request, **kwargs)  # type: ignore
  File "/usr/local/lib/python3.10/dist-packages/msrest/pipeline/async_requests.py", line 99, in send
    self._creds.signed_session(session)
  File "/usr/local/lib/python3.10/dist-packages/botframework/connector/auth/app_credentials.py", line 98, in signed_session
    auth_token = self.get_access_token()
  File "/usr/local/lib/python3.10/dist-packages/botframework/connector/auth/microsoft_app_credentials.py", line 65, in get_access_token
    return auth_token["access_token"]
KeyError: 'access_token'

根据我看过的其他文章,这个问题似乎与应用程序密码不正确有关;但是,我已经多次确认并仔细检查了这一点。我什至创建了一个新的客户端密钥来获取新的密钥,但它仍然给我完全相同的错误。

设置此测试似乎相对简单且配置更改最少,因此我不确定还有什么其他因素会对此做出贡献。

任何指点将不胜感激。

python botframework
2个回答
0
投票

虽然除了通过问答解决问题之外似乎没有记录任何内容,但现在在删除应用程序 ID 和应用程序密码时可以使用。根据 BotFramework:机器人的 MSA appId 或密码不正确,我假设这些值在调试为空时必须保持为空。


0
投票

对于 config.py 中的

MicrosoftAppPassword
,请验证您是否使用“值”作为密钥,而不是 Azure 应用程序注册证书和密钥页面中的
SecretID

© www.soinside.com 2019 - 2024. All rights reserved.