SingleTenant MS Teams Apps returns 401 - "Authorization has been denied for this request"

135 views Asked by At

I am trying to deploy a MS Teams app as a SingleTenant app. The application works perfectly as MultiTenant, but as soon as I change the details to SingleTenant, the application returns a 401 error - "Authorization has been denied for this request".

After days of combing through forums and documentation, I have no solution. Do you know what would be the trigger for this error, and how to troubleshoot effectively these issues with MS Teams app - specifically SingleTenant?

First, in the app code I changed the app type to be single tenant:

const credentialsFactory = new ConfigurationServiceClientCredentialFactory({
  MicrosoftAppId: config.botId,
  MicrosoftAppPassword: config.botPassword,
  MicrosoftAppType: "SingleTenant", // was "MultiTenant"
  MicrosoftAppTenantId: "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX" 
});

I also matched this in Azure, and changed the app to "Single Tenant" under "Authorization".

However, the app keeps on returning:

url: 'https://smba.trafficmanager.net/apac/v3/conversations/<xxxxxxx>/activities/<xxxx>',
method: 'POST',
headers: HttpHeaders { _headersMap: [Object] },
body: '{"type":"message","serviceUrl":"https://smba.trafficmanager.net/","channelId":"msteams","from":{"id":"xxxxxx","name":"bot-poc"},"conversation":{"conversationType":"personal","id":"xxxxxx","tenantId":"xxxxx"},"recipient":{"id":"xxxxxx","name":"xxxxxx","aadObjectId":"xxxxxxx"},"locale":"en-US","text":"The bot encountered an unhandled error:\\n Authorization has been denied for this request.","inputHint":"acceptingInput","replyToId":"xxxxxxxx"}',

I am not sure what I need to do for the application to be able to post responses to Teams.

0

There are 0 answers