Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get Azure Active Directory B2C working with Bot Framework?

so far I've not been able to get this working with the bot framework. I spent all day but only managed to get .net api example (https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet) working with AD B2C. I'm not sure where it grabs the bearer token that I want to pass to BotUserData...

I've tried following https://azure.microsoft.com/en-us/blog/bot-framework-made-better-with-azure/

but in reality the solution does not build successfully and I've resorted to just taking code from there and into my bot framework sample template....however, when it asks me to login through MS and I do, I am not able to proceed and it doesn't seem like that blog is using the AD B2C policies.

so how do you integrate AD B2C with Bot Framework? Is it possible to call /Account/SignIn URL from bot framework to authenticate the user? Afterwards, how would you capture the token and pass it to BotUserData?

like image 406
user299709 Avatar asked Apr 30 '16 02:04

user299709


1 Answers

You might want to take a look to the Facebook Auth sample to get an idea of a potential flow for the Auth scenario. For Azure AD, you need to do a similar flow.

Let's say your user send a "Login" message to your bot. The bot should respond with an auth URL and ask the user to login to the service using that URL. You can use the GetAuthorizationRequestURL method of ADAL for that.

Then you will have a Web API which will basically expose an endpoint that will be the reply URL of Azure AD. Once the users completes the login, a message will be posted to your Web API where you will be able to get the authorization code and perform the calls to get the Access Token. After that, you can just do the same they are doing in the Facebook Sample Web API which involves resuming the conversation with the Bot, sending a message with the access token (so it can be persisted in the PerUserInConversationData bag (check this line of code).

After that you have the access token available to perform any call that requires an access token.

Update

There are two new samples that you might want to take a look since they are implementing the workflow being discussed.

  • GraphBot from the BotBuilder repo.
  • AuthBot from Mat Velloso

Hope this helps.

like image 137
Ezequiel Jadib Avatar answered Oct 21 '22 03:10

Ezequiel Jadib