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

InternalServerError: Authorization for Microsoft App ID failed with status code Forbidden

Open enzofab91 opened this issue 10 years ago • 18 comments

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()" }

enzofab91 avatar Nov 11 '16 12:11 enzofab91

Hi @enzofab91, which channel are using? Can you send your bot handle or MSA app ID?

dandriscoll avatar Nov 11 '16 15:11 dandriscoll

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

enzofab91 avatar Nov 11 '16 16:11 enzofab91

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.

dandriscoll avatar Nov 11 '16 16:11 dandriscoll

Hi. I am having a similar issue, don't know if related.

srozga avatar Nov 11 '16 23:11 srozga

We have the same issue using the Twilio channel.

stephenpgreen avatar Nov 14 '16 15:11 stephenpgreen

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.

dandriscoll avatar Nov 14 '16 17:11 dandriscoll

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.

stephenpgreen avatar Nov 14 '16 17:11 stephenpgreen

Is this realted to https://github.com/Microsoft/BotBuilder/issues/1597 ?

vossccp avatar Nov 17 '16 09:11 vossccp

@dandriscoll anything else we can do here?

chrimc62 avatar Nov 28 '16 00:11 chrimc62

I am also facing same issue Microsoft app ID is 64f88598-8f69-4f80-a936-84147a7e71f0

nareshbonagiri avatar Nov 28 '16 13:11 nareshbonagiri

@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?

vjrantal avatar Nov 29 '16 10:11 vjrantal

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.

enzofab91 avatar Nov 30 '16 12:11 enzofab91

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

enzofab91 avatar Dec 02 '16 12:12 enzofab91

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.

dandriscoll avatar Dec 21 '16 17:12 dandriscoll

What happened with this ? Guys, did you solve this issue ?

ghost avatar Feb 24 '17 10:02 ghost

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.

dandriscoll avatar Mar 08 '17 18:03 dandriscoll

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 avatar Jun 12 '17 05:06 valnav

@valnav Have you tried adding a call to Microsoft​App​Credentials.​Trust​Service​Url(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).

EricDahlvang avatar Jun 12 '17 16:06 EricDahlvang