title: Azure WebBot-Cortana OAUTH Issue "POST to 'https://CortanaBFChannelWestUS.azurewebsites.net
body: <p><strong>Problem:</strong> </p>
  
  <p>Error: POST to '<a href="https://CortanaBFChannelWestUS.azurewebsites.net/v3/conversations/../activities/6TZfwIQ7Fqv" rel="nofollow noreferrer">https://CortanaBFChannelWestUS.azurewebsites.net/v3/conversations/../activities/6TZfwIQ7Fqv</a>' failed: [500] Internal Server Error
      at Request._callback (D:\home\site\wwwroot\node_modules\botbuilder\lib\bots\ChatConnector.js:675:46)
      at Request.self.callback (D:\home\site\wwwroot\node_modules\request\request.js:185:22)
      at emitTwo (events.js:106:13)
      at Request.emit (events.js:191:7)
      at Request. (D:\home\site\wwwroot\node_modules\request\request.js:1161:10)
      at emitOne (events.js:96:13)
      at Request.emit (events.js:188:7)
      at IncomingMessage. (D:\home\site\wwwroot\node_modules\request\request.js:1083:12)
      at IncomingMessage.g (events.js:291:16)
      at emitNone (events.js:91:20)</p>
  
  <p><strong>Architecture:</strong>
  Aure Web-Bot : NodeJS SDKv3 
  Microsoft App Dev 
  Luis
  Channels : Web/Cortana/Skype
  OAuth</p>
  
  <p><strong>Scenario:</strong> 
  Upon hitting an intent based on an utterance the app successfully displays a "sign-in" card to the user and asks the user to sign in </p>
  
  <p><a href="https://i.stack.imgur.com/HzEGl.png" rel="nofollow noreferrer">Screenshot of app sign-in </a> </p>
  
  <p>After that the user is able to successfully log in using credentials that are authenticated using OAuth for access to Office 365 </p>
  
  <p><a href="https://i.stack.imgur.com/YLhco.png" rel="nofollow noreferrer">ScreenShot after login</a></p>
  
  <p><strong>TestCase:</strong> 
  Channel Skype: Successful display and login 
  Channel Web: Successful display and login 
  Channel Cortana: Fail ( No display of "sign-in"card)</p>
  
  <p>Channel Cortana: Fail ( No display of "sign-in"card)
  Now i am using the Cortana app on an iphone and for the same utterance-intent-action this is what happens </p>
  
  <p><a href="https://i.stack.imgur.com/MI7ej.jpg" rel="nofollow noreferrer">Screen Shot Channel Cortana Invocation</a></p>
  
  <p>And the error that shows up on the console is as shown above </p>
  
  <p><strong>Notes:</strong></p>
  
  <p>Within the Web-Bot framework When it is Skype or Web as a channel the callback for the OAuth is mapped to </p>
  
  <pre><code>server.get('/api/OAuthCallback',
      passport.authenticate('azuread-openidconnect', { failureRedirect: '/'}),
      (req, res) =&gt; {
      const address = JSON.parse(req.query.state);
      const messageData = { accessToken: req.user.accessToken, refreshToken: req.user.refreshToken, userId: address.user.id, name: req.user.displayName};
      var continueMsg = new builder.Message().address(address).text(JSON.stringify(messageData));
      bot.receive(continueMsg.toMessage());
      res.send('Welcome ' + req.user.displayName + '. Login successful. You can close this browser window')
  });
  </code></pre>
  
  <p>The basic idea for the OAuth as implemented being that the URl maps to a call back as defined in the Web-App-Platform. </p>
  
  <p>But Cortana does say <a href="https://docs.microsoft.com/en-us/cortana/skills/configure-connected-account" rel="nofollow noreferrer">Cortana MSA Authentication</a> and that didnt work </p>
  
  <ol>
  <li>For one there URL maps to <a href="https://www.bing.com/agents/oauth" rel="nofollow noreferrer">https://www.bing.com/agents/oauth</a> instead of the call back defined at the web-app-bot-url/api/OAuthCallback</li>
  <li>Can someone explain how does the Authentication work for Cortana given the arch they have specified </li>
  </ol>
  
  <p>Can anyone shed some light as to what exactly is the problem i know i am missing something important as far as understanding is concerned. </p>
  
  <p>Thank you</p>