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:
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!
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.
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.
Thank you @willportnoy for the quick reply.
So I think we can close this ticket.
@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?
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?
@sogeg Exactly same problem for me. It works sometimes, then stops with this message. no idea why.
@sogeg Channel url for skype has changed to Skype
@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:
https://github.com/Microsoft/BotBuilder/issues/2575
where I have code for reproduce
Most helpful comment
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.SendToConversationAsyncSo 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.