We are facing an issue where the Azure Bot Framework Service cannot authenticate using our App Registration, even though the App Registration and Enterprise Application exist in the tenant.
Main Issue
The Bot Service immediately returns:
Unauthorized
before any OAuth, token request, MSAL flow, or Graph API call happens.
This means the failure occurs inside Bot Framework authentication, not during user authentication.
Details
App Registration exists
Enterprise Application was created after admin consent
App ID and Secret are correct
Tenant ID is correct
Admin consent has been granted
Bot Service is connected to the same App ID
But the Bot Framework still cannot sign in using this App Registration.
Question
Why is the Bot Framework Service unable to authenticate the bot using the correct App ID + Secret in our tenant?
What tenant configuration or Bot Framework requirement could cause this persistent Unauthorized response, even after consent and setup?
We need help understanding why the Bot Service itself cannot authenticate, so we can proceed with SSO and Teams integration.
Full Error 2025-12-01T06:22:22.0361467Z INFO:merford-bot:HTTP POST /api/messages (channelId=webchat) 2025-12-01T06:22:23.9897581Z INFO:merford-bot:RX activity: type=conversationUpdate name=None channel=webchat convId=83Z3xUQKNLc2gbTcntkKXP-eu svc=https://webchat.botframework.com/ 2025-12-01T06:22:25.4667663Z INFO:merford-bot:get_user_token exception: Operation returned an invalid status code 'Unauthorized'
2025-12-01T06:22:25.9760126Z ERROR:merford-bot:Exception in /api/messages: Operation returned an invalid status code 'Unauthorized'
2025-12-01T06:22:25.9760679Z Traceback (most recent call last):
2025-12-01T06:22:25.9760703Z File "/tmp/8de2e7823e842e6/bot.py", line 530, in messages
2025-12-01T06:22:25.9760729Z asyncio.run(_proc())
2025-12-01T06:22:25.9760745Z File "/opt/python/3.11.14/lib/python3.11/asyncio/runners.py", line 190, in run
2025-12-01T06:22:25.9760759Z return runner.run(main)
2025-12-01T06:22:25.9760773Z ^^^^^^^^^^^^^^^^
2025-12-01T06:22:25.9760889Z File "/opt/python/3.11.14/lib/python3.11/asyncio/runners.py", line 118, in run
2025-12-01T06:22:25.9760904Z return self._loop.run_until_complete(task)
2025-12-01T06:22:25.9760919Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-12-01T06:22:25.9760937Z File "/opt/python/3.11.14/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
2025-12-01T06:22:25.9760951Z return future.result()
2025-12-01T06:22:25.9760964Z ^^^^^^^^^^^^^^^
2025-12-01T06:22:25.976098Z File "/tmp/8de2e7823e842e6/bot.py", line 528, in _proc
2025-12-01T06:22:25.9760997Z return await adapter.process_activity(activity, auth_hdr, handle_activity)
2025-12-01T06:22:25.9761013Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-12-01T06:22:25.9761032Z File "/tmp/8de2e7823e842e6/antenv/lib/python3.11/site-packages/botbuilder/core/bot_framework_adapter.py", line 445, in process_activity
2025-12-01T06:22:25.9761066Z return await self.process_activity_with_identity(activity, identity, logic)
2025-12-01T06:22:25.9761084Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-12-01T06:22:25.9761105Z File "/tmp/8de2e7823e842e6/antenv/lib/python3.11/site-packages/botbuilder/core/bot_framework_adapter.py", line 487, in process_activity_with_identity
2025-12-01T06:22:25.9761119Z await self.run_pipeline(context, logic)
2025-12-01T06:22:25.9761139Z File "/tmp/8de2e7823e842e6/antenv/lib/python3.11/site-packages/botbuilder/core/bot_adapter.py", line 181, in run_pipeline
2025-12-01T06:22:25.9761152Z raise error
2025-12-01T06:22:25.976117Z File "/tmp/8de2e7823e842e6/antenv/lib/python3.11/site-packages/botbuilder/core/bot_adapter.py", line 174, in run_pipeline
2025-12-01T06:22:25.9761186Z return await self._middleware.receive_activity_with_status(
2025-12-01T06:22:25.9761201Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-12-01T06:22:25.9761221Z File "/tmp/8de2e7823e842e6/antenv/lib/python3.11/site-packages/botbuilder/core/middleware_set.py", line 69, in receive_activity_with_status
2025-12-01T06:22:25.9761252Z return await self.receive_activity_internal(context, callback)
2025-12-01T06:22:25.9761268Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-12-01T06:22:25.9761286Z File "/tmp/8de2e7823e842e6/antenv/lib/python3.11/site-packages/botbuilder/core/middleware_set.py", line 79, in receive_activity_internal
2025-12-01T06:22:25.9761301Z return await callback(context)
2025-12-01T06:22:25.9761315Z ^^^^^^^^^^^^^^^^^^^^^^^
2025-12-01T06:22:25.976133Z File "/tmp/8de2e7823e842e6/bot.py", line 304, in handle_activity
2025-12-01T06:22:25.9761373Z await turn_context.send_activity("👋 Hi! Please sign in to continue.")
2025-12-01T06:22:25.9761394Z File "/tmp/8de2e7823e842e6/antenv/lib/python3.11/site-packages/botbuilder/core/turn_context.py", line 174, in send_activity
2025-12-01T06:22:25.976141Z result = await self.send_activities([activity_or_text])
2025-12-01T06:22:25.9761442Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-12-01T06:22:25.9761461Z File "/tmp/8de2e7823e842e6/antenv/lib/python3.11/site-packages/botbuilder/core/turn_context.py", line 226, in send_activities
2025-12-01T06:22:25.9761478Z return await self._emit(self._on_send_activities, output, logic())
2025-12-01T06:22:25.9761493Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-12-01T06:22:25.9761512Z File "/tmp/8de2e7823e842e6/antenv/lib/python3.11/site-packages/botbuilder/core/turn_context.py", line 304, in _emit
2025-12-01T06:22:25.9761525Z return await logic
2025-12-01T06:22:25.9761539Z ^^^^^^^^^^^
2025-12-01T06:22:25.9761557Z File "/tmp/8de2e7823e842e6/antenv/lib/python3.11/site-packages/botbuilder/core/turn_context.py", line 221, in logic
2025-12-01T06:22:25.9761573Z responses = await self.adapter.send_activities(self, output)
2025-12-01T06:22:25.9761588Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-12-01T06:22:25.9761621Z File "/tmp/8de2e7823e842e6/antenv/lib/python3.11/site-packages/botbuilder/core/bot_framework_adapter.py", line 728, in send_activities
2025-12-01T06:22:25.9761635Z raise error
2025-12-01T06:22:25.9761653Z File "/tmp/8de2e7823e842e6/antenv/lib/python3.11/site-packages/botbuilder/core/bot_framework_adapter.py", line 718, in send_activities
2025-12-01T06:22:25.9761669Z response = await client.conversations.send_to_conversation(
2025-12-01T06:22:25.9761684Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-12-01T06:22:25.9761705Z File "/tmp/8de2e7823e842e6/antenv/lib/python3.11/site-packages/botframework/connector/aio/operations_async/_conversations_operations_async.py", line 260, in send_to_conversation
2025-12-01T06:22:25.976172Z raise models.ErrorResponseException(self._deserialize, response)
2025-12-01T06:22:25.9762062Z botbuilder.schema._models_py3.ErrorResponseException: Operation returned an invalid status code 'Unauthorized'

// only single tenant option i found
// selected as muliti tanent