New Version of Devenvexe Windows 10 App Released by Suthahar

Monday, January 7, 2019

Building Bot Application with Azure AD Login Authentication using AuthBot

Introduction:

The Azure AD is the identity provider, responsible for verifying the identity of users and applications and providing security tokens upon successful authentication of those users and applications.in this article I have explained about create Azure AD authentication and integrate into bot application using AuthBot library.

The Bot show very simple dialog with openUrl button and this button launches the web browser for validate user credential and AD will response the message with authentication code, you can copy same code and reply back to the bot, bot will validation and response the welcome message.

You can follow below given steps one by one and you will get to see an interesting demo at end of article.

Azure AD App registration:

I will show the steps given below for the azure application creation, user creation and permission configuration. While implementing bot application, We need Client ID, tenant, return URL, so here I will show how to get all the configuration information from the steps given below.

Step 3: You can create a new AzureADDialog class to show the default login and logout UI Design dialog. Rightclick on Project, select Add New Item, create a class that is marked with the [Serializable] attribute (so the dialog can be serialized to state), and implement the IDialog interface.

using AuthBot;

using AuthBot.Dialogs;

using Microsoft.Bot.Builder.Dialogs;

using Microsoft.Bot.Connector;

using System;

using System.Configuration;

using System.Threading;

using System.Threading.Tasks;

namespace DevAuthBot.Dialogs

{

[Serializable]

publicclassAzureADDialog : IDialog<string>

{

Step 4 :IDialog interface has only StartAsync() method. StartAsync() is called when the dialog becomes active. The method passes the IDialogContext object, used to manage the conversation.

publicasyncTask StartAsync(IDialogContext context)

{

context.Wait(MessageReceivedAsync);

}

Step 5: Create aMessageReceivedAsyncmethod and write the following code for the login and logout default dialog and create a ResumeAfterAuth for after the user login, bot will reply the user name and email id details.

No comments:

Post a Comment

About Me

Suthahar J is an industry luminary focused on AI, Computer Vision, Bot, Machine Learning, UWP, Azure, Xamarin and Web & Emerging User Experiences. He is a Technical Architect and C# Corner MVP. During his 12 years in the IT industry he has had roles in development, Lead and Architect using different Microsoft technologies on a number of large and complex projects. He is Author of Xamarin Q &A Book and published in Amazon. He is published Xamarin Q & A Bot to the Facebook Messenger, Blog, Skype and Cortana. He also enjoys sharing his passion with other people, thus actively contributing to the community via his presentations, writing technical Article and blogs which helps him becomes a better technology leader. He takes a keen interest in sharing his knowledge and solving readers’ technology-related problems. He is Founder of popular technical blog http://devenvexe.com.He was completed many Microsoft certification and received many awards. Whenever he gets the time he will go nearest orphans and stay with the child sometime and share computer skill.