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:
emailMail.ReadMail.Send.SharedopenidprofileUser.ReadUser.ReadBasic.All
- [Node.js][4] version 8.5 or higher
# determine node version node --version - Update
bot-authentication-msgraph.botwith required configuration settings- App ID and Key for registered bots
- Update
CONNECTION_SETTING_NAMEinbot.jsso the bot can perform OAuth calls through Azure Bot Service
- Clone the repository
git clone https://github.com/microsoft/botbuilder-samples.git
- In a terminal, navigate to
samples/javascript_nodejs/24.bot-authentication-msgraphcd samples/javascript_nodejs/24.bot-authentication-msgraph - Install modules
npm install
- Start the bot
npm start
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 OAuthCardsto receive the magic code
- In Settings, enable
- Launch Bot Framework Emulator
- File -> Open Bot Configuration and navigate to
samples/javascript_nodejs/24.bot-authentication-msgraphfolder - Select
bot-authentication-msgraph.botfile