Skip to content

Latest commit

 

History

History
 
 

24.bot-authentication-msgraph

Authentication Bot Utilizing MS Graph

Bot Framework v4 bot authentication using Microsoft Graph sample

This sample uses the bot authentication capabilities of Azure Bot Service. In this sample we are assuming the OAuth 2 provider is Azure Active Directory v2 (AADv2) and are utilizing the Microsoft Graph API to retrieve data about the user. Check here for information about getting an AADv2 application setup for use in Azure Bot Service. The scopes used in this sample are the following:

  • email
  • Mail.Read
  • Mail.Send.Shared
  • openid
  • profile
  • User.Read
  • User.ReadBasic.All

Prerequisites

  • [Node.js][4] version 8.5 or higher
    # determine node version
    node --version
  • Update bot-authentication-msgraph.bot with required configuration settings
    • App ID and Key for registered bots
  • Update CONNECTION_SETTING_NAME in bot.js so the bot can perform OAuth calls through Azure Bot Service

To try this sample

  • Clone the repository
    git clone https://github.com/microsoft/botbuilder-samples.git
  • In a terminal, navigate to samples/javascript_nodejs/24.bot-authentication-msgraph
    cd samples/javascript_nodejs/24.bot-authentication-msgraph
  • Install modules
    npm install
  • Start the bot
    npm start

Testing the bot using Bot Framework Emulator v4

Microsoft Bot Framework Emulator is a desktop application that allows bot developers to test and debug their bots on localhost or running remotely through a tunnel.

  • Install the Bot Framework emulator from here
    • In Settings, enable Use a sign-in verification code for OAuthCards to receive the magic code

Connect to bot using Bot Framework Emulator v4

  • Launch Bot Framework Emulator
  • File -> Open Bot Configuration and navigate to samples/javascript_nodejs/24.bot-authentication-msgraph folder
  • Select bot-authentication-msgraph.bot file

Further Reading