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 #1729

Closed
dynamicdeploy opened this issue Nov 24, 2016 · 5 comments
Closed
Assignees

Comments

@dynamicdeploy
Copy link

dynamicdeploy commented Nov 24, 2016

Hello!

I have built a bot that works great in Slack, Skype, Facebooks, etc..
The name of the bot is meelo
Now I am trying to send a proactive message to the Slack channel and I get the following error
"Authorization for Microsoft App ID xxxxxxx failed with status code Forbidden"

Here is the code. Am I doing something wrong?

class Program
{
static void Main(string[] args)
{
try
{
string appdId = ConfigurationManager.AppSettings["MicrosoftAppId"];
string appPassword = ConfigurationManager.AppSettings["MicrosoftAppPassword"];
string baseUri = ConfigurationManager.AppSettings["ConnectorClientBaseUri"];

            var client = new ConnectorClient(new Uri(baseUri), appdId, appPassword);

            //https://slack.botframework.com

                     
          
            Activity a = new Activity()
            {
                Type = ActivityTypes.Message,
                ChannelId = "slack",
                From = new ChannelAccount()
                {
                    Id = "xxxxxxx:T2CUWNSAY",
                    Name = "meelo"
                },
                Recipient = new ChannelAccount()
                {
                    Id = "xx:xxxxx",
                    Name = "tredkar"

                },
                ServiceUrl = "https://slack.botframework.com",
                Text = "Look at this!"

            };
          

            var c = client.Conversations.CreateDirectConversation(

                new ChannelAccount()
                {
                    Id = "xxxx",
                    Name = "meelo"
                },
                 new ChannelAccount()
                 {
                     Id = "xxxx:xxxxx",
                     Name = "xxxx"

                 }, a);
@msft-shahins
Copy link
Contributor

msft-shahins commented Nov 28, 2016

@dynamicdeploy MicrosoftAppCredentials only sets the JwtToken of the bot for the post requests to trusted host names. For regular incoming messages to bot, BotAuthenticator adds the service urls to the trusted set if the incoming request to bot is authenticated.

For proactive messages, your implementation needs to add the service url to the set of trusted host names using the TrustServiceUrl, if the call to connector happens in a process that haven't seen the incoming request. For example, the ResumeAsync(...) implementation shows how bot builder trusts the service url if resumption context has the IsTrustedServiceUrl flag set to true: https://github.com/Microsoft/BotBuilder/blob/db2b8f860a3d8f7744a378930f93c4b0baa97978/CSharp/Library/Microsoft.Bot.Builder/ConnectorEx/LocaleFinder.cs#L46

@ghost
Copy link

ghost commented Feb 24, 2017

All links are dead ...

@J4S0Nc
Copy link

J4S0Nc commented Mar 27, 2017

Please update the links 👎

@msft-shahins
Copy link
Contributor

links updated!

@nwhitmont
Copy link
Contributor

@J4S0Nc You are commenting on a closed issue.

If you have a question or problem, please open a new issue.

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

No branches or pull requests

6 participants