This bot has been created using Microsoft Bot Framework.
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
- 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
- [Optional] Update the .env file under samples/javascript_nodejs/24.bot-authentication-msgraph with your botFileSecret For Azure Bot Service bots, you can find the botFileSecret under application settings.
- Install modules
npm i
- Update
authentication-msgraph.bot
with required configuration settings- App ID and Key for registered bots
- Update
CONNECTION_SETTING_NAME
inbot.js
so the bot can perform OAuth calls through Azure Bot Service - Run the sample
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 OAuthCards
to receive the magic code
- Launch Bot Framework Emulator
- File -> Open Bot Configuration and navigate to
samples/javascript_nodejs/24.bot-authentication-msgraph
folder - Select
authentication-msgraph.bot
file
- Restify Used to host the web service for the bot, and for making REST calls
- dotenv Used to manage environmental variables
Update .env
with the appropriate keys:
- App ID and Key for registered bots.
- botFilePath and botFileSecret from
authentication-msgraph.bot
file