title: Unauthorized Bot Service from Web Chat
body: <p>Using Microsoft Bot Framework, I created a Chat Bot and I am able to test the Bot using local Emulator. Bot service also deals with LUIS and everything again works just fine. My Bot Service has <code>MicrosoftAppId</code> and <code>MicrosoftAppPassword</code> in <code>web.config</code>.</p>
  
  <p>I deployed the service to Azure. Then embedded a web chat in browser (<a href="https://github.com/Microsoft/BotFramework-WebChat" rel="nofollow noreferrer">Github</a>) but it doesn't work. The error say</p>
  
  <pre><code>Buffer="{
    "message": "An error has occurred.",
    "exceptionMessage": "Unauthorized",
    "exceptionType": "Microsoft.Bot.Connector.MicrosoftAppCredentials+OAuthException",
    "stackTrace": "   at Microsoft.Bot.Sample.LuisBot.MessagesController.&lt;Post&gt;d__0.MoveNext()
  
  ......
  
      "innerException": {
          "message": "An error has occurred.",
          "exceptionMessage": "Response status code does not indicate success: 401 (Unauthorized).",
          "exceptionType": "System.Net.Http.HttpRequestException",
          "stackTrace": "   at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()\r\n   at Microsoft.Bot.Connector.MicrosoftAppCredentials.&lt;RefreshTokenAsync&gt;d__26.MoveNext()"
  </code></pre>
  
  <p>I believe when I pass my Web Chat Secret Key (I have also tried to pass generated Token but no luck), then it should be authorized (passing <code>App Id</code> and <code>Password</code>) automatically. Is it not?</p>
  
  <ol>
  <li>Browser embedded web chat gives Unauthorized error.</li>
  <li>Test in Web Chat windows gives same error.</li>
  </ol>
  
  <p>I have also tried to deploy Bot service by removing <code>MicrosoftAppId</code> and <code>MicrosoftAppPassword</code> but nothing changes.</p>
  
  <p>Its all very new to me. Could someone please help me to get some clarity on this issue? Also is it fine to give away my Microsoft App Id publicly?</p>
  
  <p><strong>Edit 1</strong></p>
  
  <p>Implementation of Web Chat control in Browser. </p>
  
  <ol>
  <li>Created ASP.Net empty website and have a HTML page (index.html).</li>
  <li>Following code is written in index.html page.</li>
  </ol>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8" /&gt;
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
      &lt;div id="bot" /&gt;
      &lt;hr /&gt;
  
      &lt;iframe width="400" height="300" src='https://webchat.botframework.com/embed/#Web_App_Bot_Name#?s=Web_Chat_Secret_Key'&gt;&lt;/iframe&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <ol start="3">
  <li>Microsoft App Id = <code>f0f7297e-7a95-4a8f-afc1-eb3d19906cd0</code></li>
  <li>Screen rendered via my code looks like this. And when I send message, it says Couldn't Send. In Azure Diagnostics for App Service, I see error as Unauthorized.
  <a href="https://i.stack.imgur.com/3XGiU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3XGiU.png" alt="enter image description here"></a></li>
  </ol>