title: Azure AD integration with Bot Framework / teams
body: <p>Last week I've been looking at <a href="https://github.com/microsoft/BotBuilder-Samples/tree/master/samples/csharp_dotnetcore" rel="nofollow noreferrer">Bot framework Samples</a>, honestly BotFx isn't my area of expertise. 
  I was playing with these samples from the sample library:</p>
  
  <pre><code>18.bot-authentication
  24.bot-authentication-msgraph
  46.teams-auth
  </code></pre>
  
  <p>The required steps for making work each of them are almost the same, for #18 and make it work in the emulator this include:</p>
  
  <ul>
  <li>Register the BotApp in Azure AD</li>
  <li>Generate a Secret        </li>
  <li>Add the Redirect URI (as documented it should be: <a href="https://token.botframework.com/.auth/web/redirect" rel="nofollow noreferrer">https://token.botframework.com/.auth/web/redirect</a>)</li>
  <li>Create an azure bot service</li>
  <li>Customize the OAuth Connection Settings</li>
  </ul>
  
  <p><img src="https://i.stack.imgur.com/IHc3s.png" width="300"></p>
  
  <ul>
  <li>Then in the solution Modify appsettings.json (sample values below)</li>
  </ul>
  
  <pre><code>    {
        "ConnectionName": "juank",
        "MicrosoftAppId": "cee1234562074c-1b3e-49b4-9e76-b727d73453454e018d",
        "MicrosoftAppPassword": "uxPdfgwo.JAYmgrtU]w5I7KdgxLZSJ.a[qtgtrFxYZ02"
      }
  </code></pre>
  
  <ul>
  <li>After that It's required to run the emulator and configure the
  following settings</li>
  </ul>
  
  <p><img src="https://i.stack.imgur.com/U9zNB.png" width="300"></p>
  
  <ul>
  <li>Up to this point the bot works as expected</li>
  </ul>
  
  <p><img src="https://i.stack.imgur.com/VoTkx.png" width="400"></p>
  
  <ul>
  <li>Then I type any... and it just doesn't work. I receive this answer
  from the bot :</li>
  </ul>
  
  <p><img src="https://i.stack.imgur.com/HFAEi.png" width="400"></p>
  
  <ul>
  <li>And this data from the trace <code>Operation returned an invalid status
  code 'Unauthorized'</code></li>
  </ul>
  
  <pre><code>{
    "channelId": "emulator",
    "conversation": {
      "id": "77631280-22e8-11ea-93e0-6dc9b0b41a7c|livechat"
    },
    "from": {
      "id": "61bab030-214b-11ea-9cf4-193735472c4b",
      "name": "Bot",
      "role": "bot"
    },
    "id": "ae429e60-22e8-11ea-9786-a543cb22378b",
    "label": "TurnError",
    "localTimestamp": "2019-12-20T00:22:13-05:00",
    "locale": "en-US",
    "name": "OnTurnError Trace",
    "recipient": {
      "id": "f6982626-923e-4fd3-b930-eabf095e96df",
      "role": "user"
    },
    "replyToId": "aacb51f0-22e8-11ea-9786-a543cb22378b",
    "serviceUrl": "https://7eec83e4.ngrok.io",
    "timestamp": "2019-12-20T05:22:13.958Z",
    "type": "trace",
    "value": "Operation returned an invalid status code 'Unauthorized'",
    "valueType": "https://www.botframework.com/schemas/error"
  }
  </code></pre>
  
  <p>And that's all.</p>
  
  <p>I've successfully acquired the token from the OAuth setting Test tool in azure portal and also using Postman,  but i haven't been able to make these Demos work properly once OAuthCard should be presented for login. Debugging hasn't been helpful since there isn't other information apart from JSON exposed above.</p>
  
  <p>Any guidance or orientation about how to fix this will be appreciated.</p>