InternalServerError: Authorization for Microsoft App ID failed with status code Forbidden
I'm getting this error when trying to test my bot into the dashboard, previous to publish it . Now it’s working local and in a server by using the bot emulator.
The full stack trace is this:
InternalServerError { "message": "An error has occurred.", "exceptionMessage": "Authorization for Microsoft App ID [APP-ID] failed with status code Forbidden", "exceptionType": "System.UnauthorizedAccessException", "stackTrace": " en Microsoft.Bot.Connector.JwtTokenRefresher.d__2.MoveNext()\r\n--- Fin del seguimiento de la pila de la ubicación anterior donde se produjo la excepción ---\r\n en System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n en System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n en System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)\r\n en Microsoft.Bot.Connector.Conversations.d__8.MoveNext()\r\n--- Fin del seguimiento de la pila de la ubicación anterior donde se produjo la excepción ---\r\n en System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n en System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n en Microsoft.Bot.Connector.ConversationsExtensions.d__19.MoveNext()\r\n--- Fin del seguimiento de la pila de la ubicación anterior donde se produjo la excepción ---\r\n en System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n en System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n en FutBot.MessagesController.d__1.MoveNext()\r\n--- Fin del seguimiento de la pila de la ubicación anterior donde se produjo la excepción ---\r\n en System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n en System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n en System.Threading.Tasks.TaskHelpersExtensions.d__3`1.MoveNext()\r\n--- Fin del seguimiento de la pila de la ubicación anterior donde se produjo la excepción ---\r\n en System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n en System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n en System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext()\r\n--- Fin del seguimiento de la pila de la ubicación anterior donde se produjo la excepción ---\r\n en System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n en System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n en System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext()\r\n--- Fin del seguimiento de la pila de la ubicación anterior donde se produjo la excepción ---\r\n en System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext()\r\n--- Fin del seguimiento de la pila de la ubicación anterior donde se produjo la excepción ---\r\n en System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n en System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n en System.Web.Http.Filters.ActionFilterAttribute.d__0.MoveNext()\r\n--- Fin del seguimiento de la pila de la ubicación anterior donde se produjo la excepción ---\r\n en System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n en System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n en System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext()\r\n--- Fin del seguimiento de la pila de la ubicación anterior donde se produjo la excepción ---\r\n en System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n en System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n en System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()" }
Hi @enzofab91, which channel are using? Can you send your bot handle or MSA app ID?
Hi, I'm testing my bot from the dashboard (dev.botframework.com) before publishing it.
The MSA app ID is 5177cfac-64d5-461c-b5c0-850640e1f617
The problem is strange -- the bot should not be trying to contact our services when you contact it from the developer portal.
The developer portal will send a "Ping" activity and your bot should not try to respond.
If you want to try responses, you should connect your bot to a channel (Skype, Web Chat, etc.) and connect to your bot from there.
Hi. I am having a similar issue, don't know if related.
We have the same issue using the Twilio channel.
Hi @stevepgreen, can you send your bot handle or MSA app ID?
@enzofab91, if you see this issue on a channel, let me know which one and I can take a closer look.
We are only using the Twilio channel; our MSA App ID is : 4e8d97ea-d659-4e70-9f12-e014ba7ce063. We’ve rolled back to 3.3.0 and it’s working again.
~Steve
From: dandriscoll [email protected] Reply-To: Microsoft/BotBuilder [email protected] Date: Monday, November 14, 2016 at 11:21 AM To: Microsoft/BotBuilder [email protected] Cc: Steve Green [email protected], Mention [email protected] Subject: Re: [Microsoft/BotBuilder] InternalServerError: Authorization for Microsoft App ID failed with status code Forbidden (#1641)
Hi @stevepgreenhttps://github.com/stevepgreen, can you send your bot handle or MSA app ID?
@enzofab91https://github.com/enzofab91, if you see this issue on a channel, let me know which one and I can take a closer look.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Microsoft/BotBuilder/issues/1641#issuecomment-260399991, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ASw_D0yofTnlqfIxmBvC7BJFWVkMjxgAks5q-JibgaJpZM4KvuY8.
Wirestream, LLC Steve Green Chief Digital Officer email: [email protected] phone: 816.406.1000mobile: 913.433.3004 office: 521 Walnut Street, Kansas City, Missouri This message contains confidential information and is only for the specified recipients. If you are not an intended recipient you should not disseminate, distribute or copy this e-mail. If you received this message by mistake, please notify the sender immediately and delete it from your system.
Is this realted to https://github.com/Microsoft/BotBuilder/issues/1597 ?
@dandriscoll anything else we can do here?
I am also facing same issue Microsoft app ID is 64f88598-8f69-4f80-a936-84147a7e71f0
@dandriscoll I was wondering could this and https://github.com/Microsoft/BotBuilder/issues/1729 relate to the following issue we noticed.
When creating the ConnectorClient without passing app id and password (e.g., like this https://github.com/Microsoft/BotBuilder/blob/5cf71c742f27d89e9dbc4076f850122bd6edac11/CSharp/Samples/Stock_Bot/Basic_Luis_StockBot/Controllers/MessagesController.cs#L29 ) things work correctly and the values are read from the Web.config file. However, if you remove the values from Web.config and explicitly pass them to ConnectorClient, you see an error like discussed here.
I see that here https://github.com/Microsoft/BotBuilder/issues/1729#issue-191423328 the values are passed in a way that according our tests, causes an issue:
var client = new ConnectorClient(new Uri(baseUri), appdId, appPassword);
@enzofab91 and @nareshbonagiri: How are you passing the app id and password when you see this issue?
Hi, sorry for the delay in responding, I was facing issues with other tasks.
I'm passing the app id and pasword in the web.config. The Bot Builder version es 3.0.0
Also, when receiveng ping I'm responding an activiy of type Ping with some text. Is this ok?
Edit: I've upgraded to 3.3.3 and facing the same issue. I can't publish the bot in any channel because that and testing is failing.
I have managed to solve it. I was executing ReplyToActivityAsync(message) to a Ping and for any reason it returns the error. If I send a null reply it works fine
Hi @enzofab91, that's correct, replying to a Ping message will result in an error. Closing this error as we have identified the source of the problem.
What happened with this ? Guys, did you solve this issue ?
There are two issues in the thread above:
- Some bots respond to Ping messages sent from the dev portal. This will result in an error.
- There was an auth bug in our C# SDK that was fixed in 3.5.3. Please upgrade if you encounter auth issues.
I am using 3.8 version. my scenario is that a asp.net website posts to a customAPIcontroller which calls this method and tries to send the message. But i get the same error - unauthorized 401. in the stack trace its coming from JwtRefresher
` connector = new ConnectorClient(new Uri("https://email.botframework.com"), new
MicrosoftAppCredentials
{
MicrosoftAppId = ConfigurationManager.AppSettings["MicrosoftAppId"],
MicrosoftAppPassword = ConfigurationManager.AppSettings["MicrosoftAppPassword"]
});
List<ChannelAccount> participants = new List<ChannelAccount>();
participants.Add(new ChannelAccount(email, name));
botAccount = new ChannelAccount("[email protected]", "Admin2");
ConversationParameters cpMessage = new ConversationParameters(true, botAccount, participants, subject);
ConversationResourceResponse conversationId = null;
try {
conversationId = await connector.Conversations.CreateConversationAsync(cpMessage);
} catch(Exception ex)
{
Trace.TraceError(ex.Message);
}
IMessageActivity message = Activity.CreateMessageActivity();
message.From = botAccount;
message.Recipient = new ChannelAccount(email, name);
message.Conversation = new ConversationAccount(id: conversationId?.Id);
message.ChannelId = "email";
message.Text = body;
message.Locale = "en-Us";
await connector.Conversations.SendToConversationAsync((Activity)message);`
@valnav Have you tried adding a call to MicrosoftAppCredentials.TrustServiceUrl(message.ServiceUrl) ? Please see here: https://docs.microsoft.com/en-us/dotnet/api/microsoft.bot.connector.microsoftappcredentials.trustserviceurl
This issue is closed. Please either open a new issue, or post your question on Stack Overflow (the preferred location for Bot Framework questions).