botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

Send message to conversation Failed with status code Forbidden

Open slpdy opened this issue 8 years ago • 1 comments

Bot Info

  • SDK Platform: NET
  • SDK Version: 3.13.0.3
  • Active Channels: MS Teams
  • Deployment Environment: Migrated to new Bot Service, deployed on Azure App Service

Issue Description

I didn't change anything on the code and all of the sudden I started to have a minimum of 5x exceptions per hour (can easily escalate to 50-100x exceptions per hour):

"An error has occurred.", "exceptionMessage": "Authorization for Microsoft App ID [...] failed with status code Forbidden and reason phrase 'Forbidden'", "exceptionType": "System.UnauthorizedAccessException", "stackTrace": " at Microsoft.Bot.Connector.JwtTokenRefresher.d__2.MoveNext()\r\n---

I have already update all Nuget packages (JWT is on 5.2.0 the latest on available). Only thing I changed recently, was migrating to new Bot Service.

Code Example

I already had the following

MicrosoftAppCredentials.TrustServiceUrl("https://smba.trafficmanager.net/amer-client-ss.msg/");

and now changed to the below in case could had something to do with it:

MicrosoftAppCredentials.TrustServiceUrl("https://smba.trafficmanager.net/amer-client-ss.msg/", DateTime.Now.AddDays(7)); var account = new MicrosoftAppCredentials(ConfigurationManager.AppSettings["MicrosoftAppId"], ConfigurationManager.AppSettings["MicrosoftAppPassword"]); var connector = new ConnectorClient(new Uri("https://smba.trafficmanager.net/amer-client-ss.msg/"), account);

Reproduction Steps

  1. Directline sends message to BOT
  2. Bot send messages to users on Microsoft Teams connector.Conversations.SendToConversation(conversationId, (Activity)messageActivity);

Expected Behavior

Flow to work well.

Actual Results

Some messages aren't being delivered due to this.

slpdy avatar Feb 02 '18 23:02 slpdy

I managed to found out what it is. If you manually block the Bot in 1:1 chat conversation on Microsoft Teams, this is the exception that will be raised.

slpdy avatar Feb 05 '18 09:02 slpdy