Forum Discussion
norxnd
Nov 20, 2020Brass Contributor
Bot framework cannot find auth token.
2020-11-20T10:33:55.530099+00:00 app[web.1]: await context.send_activity(Activity(type=ActivityTypes.typing))
2020-11-20T10:33:55.530099+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/botbuilder/core/turn_context.py", line 174, in send_activity
2020-11-20T10:33:55.530099+00:00 app[web.1]: result = await self.send_activities([activity_or_text])
2020-11-20T10:33:55.530100+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/botbuilder/core/turn_context.py", line 226, in send_activities
2020-11-20T10:33:55.530100+00:00 app[web.1]: return await self._emit(self._on_send_activities, output, logic())
2020-11-20T10:33:55.530100+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/botbuilder/core/turn_context.py", line 304, in _emit
2020-11-20T10:33:55.530100+00:00 app[web.1]: return await logic
2020-11-20T10:33:55.530101+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/botbuilder/core/turn_context.py", line 221, in logic
2020-11-20T10:33:55.530101+00:00 app[web.1]: responses = await self.adapter.send_activities(self, output)
2020-11-20T10:33:55.530101+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/botbuilder/core/bot_framework_adapter.py", line 729, in send_activities
2020-11-20T10:33:55.530101+00:00 app[web.1]: raise error
2020-11-20T10:33:55.530102+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/botbuilder/core/bot_framework_adapter.py", line 714, in send_activities
2020-11-20T10:33:55.530102+00:00 app[web.1]: response = await client.conversations.reply_to_activity(
2020-11-20T10:33:55.530102+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/botframework/connector/aio/operations_async/_conversations_operations_async.py", line 528, in reply_to_activity
2020-11-20T10:33:55.530103+00:00 app[web.1]: response = await self._client.async_send(
2020-11-20T10:33:55.530103+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/msrest/async_client.py", line 115, in async_send
2020-11-20T10:33:55.530103+00:00 app[web.1]: pipeline_response = await self.config.pipeline.run(request, **kwargs)
2020-11-20T10:33:55.530103+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/msrest/pipeline/async_abc.py", line 159, in run
2020-11-20T10:33:55.530103+00:00 app[web.1]: return await first_node.send(pipeline_request, **kwargs) # type: ignore
2020-11-20T10:33:55.530108+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/msrest/pipeline/async_abc.py", line 79, in send
2020-11-20T10:33:55.530108+00:00 app[web.1]: response = await self.next.send(request, **kwargs) # type: ignore
2020-11-20T10:33:55.530108+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/msrest/pipeline/async_requests.py", line 99, in send
2020-11-20T10:33:55.530109+00:00 app[web.1]: self._creds.signed_session(session)
2020-11-20T10:33:55.530109+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/botframework/connector/auth/app_credentials.py", line 98, in signed_session
2020-11-20T10:33:55.530109+00:00 app[web.1]: auth_token = self.get_access_token()
2020-11-20T10:33:55.530109+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/botframework/connector/auth/microsoft_app_credentials.py", line 65, in get_access_token
2020-11-20T10:33:55.530109+00:00 app[web.1]: return auth_token["access_token"]
2020-11-20T10:33:55.530110+00:00 app[web.1]: KeyError: 'access_token'
It worked before, I didn't change code but anyway it's framework-side I think. Of course, I have a token from the auth header. It looks like this:
Bearer eyJ...6wQ
And Im putting in adapter process:
loop.run_until_complete(loop.create_task(ADAPTER.process_activity(activity, auth_header, api_handler)))
Activity is:
activity = Activity().deserialize(body)
And api_handler is my function that handle new messages. Problem occurs when I try to send activity via TurnContext.
- Varaprasad-MSFTMicrosoft
- norxndBrass Contributor
Varaprasad-MSFT First, this sample is for Csharp dotnet core but Im using Python. Second idk. Are you trying to send message to user using with authentication? I have token from header and Im putting it into Adapter and then sending activity via
TURN CONTEXT GIVEN BY ADAPTER.send_activity()
I didn't change this part of the code and it stopped working on Friday.
- Varaprasad-MSFTMicrosoft
Here is the Sample in Python, please have a look for reference and let us know if you need any help.