Abhishek Mishra
Abhishek Mishra

Reputation: 85

Error for python bot-framework: Unauthorized Access. Request is not authorized

I am working with a python based bot using the bot-framework. I am using the sample cookiecutter echo template. Echo Bot

I have deployed the bot code as a AWS lambda function, connected via API gateway. Bot emulator testing with NO APP credentials are successful.

I am getting error when i am trying to test it with registered APP ID and APP Password. I have registered my bot using the following url: dev bot framework

Do i need to add any additional authentication provision in my bot? It will be great if someone can point me to the correct direction. Thanks!

This is the error trace back:

Traceback (most recent call last):
  File "C:\Users\abhishek.mishra\AppData\Local\Programs\Python\Python36\lib\site-packages\botbuilder\core\bot_framework_adapter.py", line 209, in process_activity
    await self.authenticate_request(activity, auth_header)
  File "C:\Users\abhishek.mishra\AppData\Local\Programs\Python\Python36\lib\site-packages\botbuilder\core\bot_framework_adapter.py", line 241, in authenticate_request
    self.settings.channel_service,
  File "C:\Users\abhishek.mishra\AppData\Local\Programs\Python\Python36\lib\site-packages\botframework\connector\auth\jwt_token_validation.py", line 42, in authenticate_request
    raise Exception("Unauthorized Access. Request is not authorized")
Exception: Unauthorized Access. Request is not authorized

Upvotes: 2

Views: 1437

Answers (1)

Abhishek Mishra
Abhishek Mishra

Reputation: 85

I will answer this question myself as i was able to work around the error. It does bring up certain security issues but resolves the invalid access issue.

As per the documentation Bot Registration

In the section Supports account types, you must choose one of the 2 multi-tenant types that is: Accounts in any organizational directory (Any Azure AD - Multitenant) or Accounts in any organizational directory (Any Azure AD - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox, Outlook.com), when creating the app, otherwise the bot will not work.

Making this change to the App registration resolved the error and the service is working fine. Thanks to everyone that tried to chip in with their inputs.

Upvotes: 1

Related Questions