OfficeDev / Microsoft-Teams-Samples

Welcome to the Microsoft Teams samples repository. Here you will find task-focused samples in C#, JavaScript and TypeScript to help you get started with the Microsoft Teams App!
MIT License
980 stars 763 forks source link

Encoutering "Error: Authorization has been denied for this request" #658

Closed hungngocphat01 closed 1 year ago

hungngocphat01 commented 1 year ago

Hi,

I'm new to MS Bot Framework, and I am encountering an issue. I have cloned this repository and ran the NodeJS bot-conversation sample, following the exact same steps as described in the README file:

However, when I try to send any message to the bot (either from Web Chat or Teams), I always get the following error: Error: Authorization has been denied for this request. It is caught in the onTurnError method in index.js. I'm running the exact same code as provided in the repository, without any modifications and it is still not working. What could be the possible solution to this problem?

Thank you.

ChetanSharma-msft commented 1 year ago

Hello @hungngocphat01 - Thanks for raising your query. We will look into it and let you know the updates.

Pawan-MSFT commented 1 year ago

Hello @hungngocphat01 - Could you please follow below steps:

1) Create a new app registration in your Tenant with multi-tenant. 2) Add "MultiTenant(default)" value for MicrosoftAppType in your .env file. 

Note: No need to configure UserAssignedMSI in bot.

Please try it and let us know, if you still face any issue.

Meghana-MSFT commented 1 year ago

@hungngocphat01 - Can you please try above steps and let us know if that helped?

hungngocphat01 commented 1 year ago

@Meghana-MSFT @Pawan-MSFT - Hi, I'm sorry for the late reply. By default, I cannot access the Azure app registration section in my work Azure account.

I've tried with my personal account by creating a multi-tenant app registration in Azure, plus a new bot registration at dev.botframework.net. It finally worked without any issues so far.

Just have one final question. Does local bot hosting (for experimenting) with ngrok require a multi-tenant app registration? If so, please add a brief clarification to the framework docs to inform any future developers who could experience a similar problem, since not everyone is familiar with the Azure authentication policies.

Thank you very much for your support.

Pawan-MSFT commented 1 year ago

@hungngocphat01 It is not mandatory to use multi-tenant app, but if you are using single tenant then your app registration and your azure bot registration should be in same tenant. Please let us know if you have further questions.

ChetanSharma-msft commented 1 year ago

We are closing this issue for now, please feel free to reopen it, if required.