microsoft / BotBuilder-Samples

Welcome to the Bot Framework samples repository. Here you will find task-focused samples in C#, JavaScript/TypeScript, and Python to help you get started with the Bot Framework SDK!
https://github.com/Microsoft/botframework
MIT License
4.38k stars 4.88k forks source link

Bot Authentication Graph throws exception #2488

Closed splumber closed 4 years ago

splumber commented 4 years ago

Github issues for Bot Authentication MSGraph

Sample information

  1. Sample type: \samples\csharp_dotnetcore\24.bot-authentication-msgraph
  2. Sample language: dotnetcore
  3. Sample name: <24.bot-authentication-msgraph>

Describe the bug

Objective is to deploy a bot able to send an OAuth Card. I followed the Add authentication to a bot tutorial along with the directions in the Readme. I get an ""Operation returned an invalid status code 'Unauthorized'"" exception in AdapterWithErrorHandler.OnTurnError when testing with the Bot Framework Emulator (connected to bot with the AppId and password - same in appsettings.json)

To Reproduce

Steps to reproduce the behavior:

  1. Follow Add authentication to a bot tutorial
  2. Add the AAD Client Id and Password to appsettings.json and launch the Bot via Visual Studio
  3. Connect to Bot with the Bot Framework Emulator with the above Client Id and Password
  4. Break point at AdapterWithErrorHandler Line 19

Expected behavior

An OAuth Card should be displayed.

Screenshots

If applicable, add screenshots to help explain your problem. image

Additional context

The purpose of this is to deploy a Bot sending an OAuth Card to test with the Windows Voice Assistant Client. I want to modify the client to render an OAuth Card

[bug]

anusharr commented 4 years ago

@splumber, I tried the sample 24.bot-authentication-msgraph and it works just fine for me. image

You need to add the Microsoft bot app ID and password along with the connectionName in the appsettings.json, not the client ID and password. The client ID and secret which you generate in the 'Create an AAD app' step is used to register your Azure AD application with your bot. Also, did you test your connection to see if it was working?

splumber commented 4 years ago

Thank you for replying, I tested the Connection and it worked Yes, I entered the MicrosoftAppId, MicrosoftAppPassword, and ConnectionName to both appsettings.json and in the BotFramework Emulator.

I'll retry all of the steps and will follow up with results

splumber commented 4 years ago

Resolved, I was not entering the Microsoft App ID from the Bot Channels Registration Resource