What's the difference between the Directline API and OAuth2 in Microsoft Bot Framework .Net?

Viewed 199

I'm thinking of how to implement Authentication in my Bot Project. My Boss wants Directline API from Azure as our go-to but there is no useful documentation provided by the Microsoft team. Another authentication is OAuth2 from Azure. Are these two similar? I know they both provide an Authentication token. But I would like to hear any suggestions from you guys.

I need to embed my Bot to the React Web-App. My plan is to only use the Bot if the user is logged-in within the App. So if it does whenever the user type/send message to the Bot. I need to authenticate that request and so on.

1 Answers

The Direct Line service (along with other channel connectors) in the bot framework utilizes Oauth. The connector service lives (and handles communication) between the chat client and the bot (your code). This is related to authenticating and handling communication between these endpoints. The bot resource (bot channels registration or web app bot) actually is dependent on an Azure AAD application that gets created along with that resource (uses client secret, etc).

Additionally, user authentication can be done, and there are bot framework SDK samples on how to implement that (let me know if you need examples).

Samples:

  • Here is the main samples repo with readme.
  • Here are the .NET (core) specific ones.
  • Here is a sample that shows user authentication using OAuth. Remember this is different than client (Teams or Slack application for example) or channel authentication. This is regarding authenticating a user to the bot through OAuth. The readme contains this link already, but make sure you read and follow this article on how to add authentication.
  • Here is a sample using OAuth but also has calls utilizing that, to make calls to MSGraph.
Related