Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authorization for Microsoft App ID failed with status code Forbidden #2003

Closed
lisitsyn-a opened this issue Jan 10, 2017 · 8 comments
Closed

Comments

@lisitsyn-a
Copy link

lisitsyn-a commented Jan 10, 2017

Hi guys!

I know there are a lot of similar issue related to authorization,
But I faced with mine several hours ago. My bot had working fine and I had not change(deploy) anything with it when it stop working.

Here is a more details about the issue:
My bot has two types of messages:

  • Messages in a dialog mode.
  • Proactive messages.

The bot IS working fine when it reply to a user in a Dialog mode.
But when it send message via connector.Conversations.SendToConversationAsync (proactive message) it started fail with UnauthorizedAccessException.

Here is a stack trace:
2017-01-10T07:32:47 PID[4732] Error An error has occurred: System.UnauthorizedAccessException: Authorization for Microsoft App ID ##### failed with status code Forbidden at Microsoft.Bot.Connector.JwtTokenRefresher.<SendAsync>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.<SendToConversationWithHttpMessagesAsync>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.<SendToConversationAsync>d__15.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 DeploymentBot.WebApp.NotifierService.<SendAsync>d__3.MoveNext().

Again, the bot is working fine for the past two weeks and no changes were made.

I use my bot with Skype channel.

Thank you!

@lisitsyn-a
Copy link
Author

lisitsyn-a commented Jan 10, 2017

I found a root of my issue.

My bot has a predefined list of users in order to being able to send them proactive messages.
I store user and conversation info in a following manner:
`"name": "User name",
"id": "29:####",
"channelUrl": "https://skype.botframework.com",
"conversationId": "29:###",
"botId": "28:###"

Using this information I am able to send proactive message to a user via connector.Conversations.SendToConversationAsync

So the reason I started getting an error was in a fact that skype channelUrl have been changed.
The current URL for skype is "https://smba.trafficmanager.net/apis".

After changing it the issue was solved.

But now I have a question:
How can I resolve the proper serviceUrl using channelId (skype) at runtime?
If it is impossible, what is a proper way to send proactive message to a user?

Thank you in advance.

@willportnoy
Copy link
Member

I don't think we have a mechanism yet to resolve the ServiceURL based on the Channel ID, but it's an understandable request. For now, the best practice is to save the ServiceURL.

@lisitsyn-a
Copy link
Author

Thank you @willportnoy for the quick reply.

So I think we can close this ticket.

@alokraj68
Copy link

@willportnoy How long is the validity of a conversation. when I tried the messaging, I found it to be less than 24 hrs. is it so?

@sogeg
Copy link

sogeg commented Apr 9, 2017

I face the same problem as @alokraj68 . I use the same method by saving the
`"name": "User name",
"id": "29:####",
"channelUrl": "https://skype.botframework.com",
"conversationId": "29:###",
"botId": "28:###"

At first the SendToConversationAsync works fine. But after about 20 hours I get:
Authorization for Microsoft App ID ### failed with status code Unauthorized and reason phrase 'Unauthorized'
Any ideas?

@alokraj68
Copy link

@sogeg Exactly same problem for me. It works sometimes, then stops with this message. no idea why.

@alokraj68
Copy link

@sogeg Channel url for skype has changed to Skype

@sogeg
Copy link

sogeg commented Apr 10, 2017

@alokraj68 Thank you. I copied @lisitsyn-a comment to indicate that I am using the same method. However the issue remains. I get the exception after some time..... Any ideas?

I also opened a new issue at:
#2575
where I have code for reproduce

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants