Botframework-sdk: System.UnauthorizedAccessException: Authorization for Microsoft App ID XXXX failed with status code Forbidden

Created on 14 Jul 2016  路  20Comments  路  Source: microsoft/botframework-sdk

Hi,

After migrate do V3, I have this message trying to send messages (in Telegram, Kik, Slack):

In Skype, Email and WebChat it is ok.

System.UnauthorizedAccessException: Authorization for Microsoft App ID XXXXXX failed with status code Forbidden
at Microsoft.Bot.Connector.JwtTokenRefresher.d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Connector.Conversations.d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Connector.ConversationsExtensions.d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Connector.ConversationsExtensions.SendToConversation(IConversations operations, Activity activity)

bug

Most helpful comment

I have updated to 3.1.0 version and still facing this bug

All 20 comments

Thank you for reporting. We're investigating this issue.

Hi @rmatosaw, can you send your Bot ID or MSA App ID?

Hi, dandriscoll. Here is the complete message.

In out scenario, sometimes we rebuild the conversation using the last conversationId.
We did it some days after migrate to V3, but today we couldn't send messages (reply to messages) in Kik, Telegram, etc. Also, we have alerts is this channel: "_Sorry, NOVIGO_OMNI is having a problem responding right now._"

Thanks

System.UnauthorizedAccessException: Authorization for Microsoft App ID 803aa38b-996f-4e3c-b34f-d8c20ac20d8c failed with status code Forbidden
at Microsoft.Bot.Connector.JwtTokenRefresher.d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Connector.Conversations.d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Connector.ConversationsExtensions.d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Connector.ConversationsExtensions.SendToConversation(IConversations operations, Activity activity)

Perfect -- thank you.

Any ideas to solve or work around?
Thanks

Not yet, sorry. Still working on it.

Hi dandriscoll. Do you think if I create a new robot I will have the same problem?
sorry for my insistence. But some key channels for me are without work, and I have to deliver them next week.
If so, I recreate it again on the Microsoft Bot (and keep the accounts of each Kik bot, Telegram, etc) and I re-apply for a new Bot.

Hi, I still have this message. Working on V3 only in Skype and Office365.

Telegram, Slack, Kik: _Sorry, NOVIGO_OMNI is having a problem responding right now._
Skype: Calls to your bot are failing with: 500 InternalServerError

Please, what can I try?

Thanks

We're still working on pinning this down. There's some revised code in our Telegram service -- are you still seeing the problem there?

Hi dandriscoll.
Thanks for your reply.

I just change my code (C #) to keep a dictionary the Activity and then use the method "ReplyToActivity" (in all scenarios for our implementation we will respond to messages asynchronously).

With this change, the situation of the channels looked like this:

  • Skype: running (responding normally) but the status on the dashboard continues with error 500.
  • Kik: respond normally, but the status on the dashboard continues with error.
  • Telegram: back to answer, while still showing in the app "Sorry, xxx is having a problem responding right now.". On the dashboard the status is "Error".

After this implementation, the error [System.UnauthorizedAccessException: Authorization for Microsoft App ID XXXX failed with status code Forbidden] apparently stopped to occur. This is apparently related to the recreation of the Conversation object (even though I was using the same previous ConversationId). Now, I am using the same activity object of the received message.

So in summary (sorry for the long message): the Telegram continues to indicate problems, and the dashboard continues to indicate errors (in Kik, Telegram, Skype), but Exception is no longer occurring.

Do you need any more information? Thanks for the support.

That should get us started. Thanks!

@dandriscoll I am facing same error in slack when I try to start a conversation with a user with following code:

ConnectorClient connector = new ConnectorClient(new Uri(incomingMessage.ServiceUrl));
            var ConversationId = await connector.Conversations.CreateDirectConversationAsync(incomingMessage.Recipient, incomingMessage.From);
            IMessageActivity message = Activity.CreateMessageActivity();
            message.Recipient = new ChannelAccount(id: "@userId", name: "username"); ;
            message.Conversation = new ConversationAccount(id: ConversationId.Id);
            message.Text = "Hello";
            message.Locale = "en-Us";
            return connector.Conversations.SendToConversation((Activity)message);

Any suggestions or work around?

@niyatia try setting message.From to your botId
message.From = new ChannelAccount { Id = "BotId", Name = "BotId" };

@RaffaelHold I added the message.From but it still gives the same error. Just to clarify, we need to set both Id and Name, both as the BotId?

@niyatia I'm sorry set the name as the bots name

@RaffaelHold Thanks. that worked.

I have updated to 3.1.0 version and still facing this bug

Authorization for Microsoft App ID f196f57b-5b97-4653-aaac-d98824071ed1 failed with status code Unauthorized {Bot Framework V 3.5.1}

Updated bot builder sdk to V3.5.1 from V3.1.0

at Microsoft.Bot.Connector.JwtTokenRefresher.d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.Bot.Connector.Conversations.d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Connector.ConversationsExtensions.d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Synechron.MortgageBot.MessagesController.d__0.MoveNext() in C:Users\Anand.Chitale\MortgageBot\Synechron.MortgageBot\Synechron.MortgageBot\Controllers\MessagesController.cs:line 54

Works fine with version 3.1.0

Hi @AnandChitale, can you open a new issue? This is likely a new problem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kenyeung128 picture kenyeung128  路  3Comments

jschristophe picture jschristophe  路  3Comments

Vigneshramkumar picture Vigneshramkumar  路  3Comments

Arimov picture Arimov  路  3Comments

akakoychenko picture akakoychenko  路  3Comments