botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

[Question] Authentication through bot framework

Open RaoVenka opened this issue 9 years ago • 2 comments

How to do authentication through Microsoft bot framework.Could please provide some samples too.

RaoVenka avatar Jun 17 '17 10:06 RaoVenka

@RaoVenka are you using .NET or Node SDK?

nwhitmont avatar Jun 19 '17 14:06 nwhitmont

You might want to start by watching this video: https://channel9.msdn.com/Shows/Office-Dev-Show/Office-Dev-Show-Episode-34-Getting-Started-with-Bots-and-the-Microsoft-Graph

Next, you can study this code example which demonstrates a Bot Framework integration with Active Directory. https://github.com/MicrosoftDX/AuthBot

You might also consider looking at the Sign-in Card example, which can also be used to authenticate your bot via web sign-in.

Docs:

  • https://docs.microsoft.com/en-us/bot-framework/dotnet/bot-builder-dotnet-add-rich-card-attachments#add-a-sign-in-card-to-a-message

Code example:

  • https://github.com/Microsoft/BotBuilder-Samples/tree/master/CSharp/cards-RichCards

Sign-in Card:

Activity replyToConversation = message.CreateReply("Should go to conversation");
replyToConversation.Attachments = new List<Attachment>();

List<CardAction> cardButtons = new List<CardAction>();

CardAction plButton = new CardAction()
{
    Value = $"https://<OAuthSignInURL",
    Type = "signin",
    Title = "Connect"
};

cardButtons.Add(plButton);

SigninCard plCard = new SigninCard(title: "You need to authorize me", button: plButton);

Attachment plAttachment = plCard.ToAttachment();
replyToConversation.Attachments.Add(plAttachment);

var reply = await connector.Conversations.SendToConversationAsync(replyToConversation);

nwhitmont avatar Jun 19 '17 15:06 nwhitmont