In this demo, you will demonstrate the construction of a configurable tab that acquires an access token from Azure Active Directory and calls the Microsoft Graph API.
This demo requires the registration of multiple applications in Azure Active Directory (Azure AD), the Bot Framework and the Azure Portal. The LabFiles folder of this module contains a file named AppWorksheet.txt which can be used to record the various ids and secrets generated and used in the demo.
Developing apps for Microsoft Teams requires preparation for both the Office 365 tenant and the development workstation.
For the Office 365 Tenant, the setup steps are detailed on the Prepare your Office 365 Tenant page. Note that while the getting started page indicates that the Public Developer Preview is optional, this lab includes steps that are not possible unless the preview is enabled. Information about the Developer Preview program and participation instructions are detailed on the What is the Developer Preview for Microsoft Teams? page.
This demo requires delegated permissions that are consented by a tenant administrator. If you are not an administrator in your tenant, you can request a developer tenant through the Office 365 developer program
The Azure Bot service requires an Azure subscription. A free trial subscription is sufficient.
As Microsoft Teams is an entirely cloud-based product, it requires all services it accesses to be available from the cloud using HTTPS endpoints. To enable the exercises to work within Microsoft Teams, a tunneling application is required.
This lab uses ngrok for tunneling publicly-available HTTPS endpoints to a web server running locally on the developer workstation. ngrok is a single-file download that is run from a console.
Make the following updates to the demo solution.
-
Launch Visual Studio 2017 as an administrator: right-click Visual Studio 2017 and select Run as administrator.
-
In Visual Studio 2017, select File > Open > Project/Solution.
-
Select the officedev-talent-management.sln file from the Demos\01-add-authentication-tab\solution folder.
-
In Solution Explorer, double-click on Properties.
-
In the Properties designer, select the Web tab.
-
Note the Project URL.
-
Open a new Command Prompt window.
-
Change to the directory that contains the ngrok.exe application.
-
Run the command
ngrok http [port] -host-header=localhost:[port]
. Replace[port]
with the port portion of the URL noted above. -
The ngrok application will fill the entire prompt window.
NOTE: Record the Forwarding address using https on the AppWorksheet as the "ngrok forwarding address".
-
Minimize the ngrok command prompt window. It is no longer referenced in this lab, but it must remain running.
-
Open the Azure Active Directory admin center.
-
Log in with the work or school account that is an administrator in the tenant.
-
Select Azure Active Directory in the left-most blade.
-
Select App registrations in the left-hand menu.
-
Select New registration.
-
Enter a name for the application. A suggested name is
Talent Management application
which distinguishes this application from the bot. Select Register. -
In the Overview blade, copy the Application (client) ID.
NOTE: Record the Application (client) ID on the AppWorksheet as the AzureAppID.
-
In the Overview blade, , copy the Directory (tenant) ID.
NOTE: Record the Directory (tenant) ID on the AppWorksheet as the AzureTenantID.
-
Select Authentication in the left-hand menu.
-
In the **Redirect URIs section, enter the following address for the Redirect URI. Replace the token
[from-ngrok]
with the value recorded on the AppWorksheet as ngrok forwarding address id. (The Sign-in URL is case-sensitive.) Leave the Type as Webhttps://[from-ngrok].ngrok.io/Tabs/auth-end.html
-
In the Implicit grant section, select Access tokens and ID tokens.
-
Select Save from the toolbar at the top of the Authentication blade.
-
Select API permissions in the left-had menu.
-
In the API permissions blade, select Add a permission. Select Microsoft Graph. Select Delegated permissions.
-
The following permissions are required for the lab. Select any that are not included by default:
- openid (Sign users in)
- profile (View users' basic profile)
- Group > Group.Read.All (Read all groups)
- User > User.Read (Sign in and read user profile)
- User > User.Read.All (Read all users' full profiles)
Select Add permissions.
Select Grant admin consent for [Directory]. Select Yes in the confirmation banner.

The Visual Studio project must be updated with information from the registration.
-
In Visual Studio, open file auth-start.html in the Tabs folder.
- Replace the token
[AzureAppID]
with the value recorded on the AppWorksheet as AzureAppID.
- Replace the token
-
In the Manifest folder , open the manifest.json file. The manifest.json file requires several updates:
- The
packageName
property must contain a unique identifier. The industry standard is to use the bot's URL in reverse format. Replace the token[from-ngrok]
with the value record on the AppWorksheet as ngrok forwarding address id. - The
developer
property has three URLs that should match the hostname of the Messaging endpoint. Replace the token[from-ngrok]
with the value record on the AppWorksheet as ngrok forwarding address id. - The
configurableTabs
property also contains a URL. Replace the token[from-ngrok]
with the value record on the AppWorksheet as ngrok forwarding address id. - The
validDomains
property requires a string array of all domains that will be accessed by the Teams app. Replace the token[from-ngrok]
with the value record on the AppWorksheet as ngrok forwarding address id. - Save and close the manifest.json file.
- The
-
Press F5 to compile, create the package and start the debugger.
Although not strictly necessary, in this demo the app is added to a new team.
-
In the Microsoft Teams application, click the Add team link. Then click the Create team button.
-
Enter a team name and description. Select Next.
-
Invite others from the organization to the team. The demo provides more impact with members in addition to the owner.
-
The new team is shown. In the left-side panel, select the ellipses next to the team name. Choose Manage team from the context menu.
-
On the Manage team display, select Apps in the tab strip. Then select the Upload a custom app link at the bottom right corner of the application.
-
Select the zip file from the bin folder that represents your app. Select Open.
-
The app is loaded to the Team. The description and icon for the app is displayed.
Configurable tabs are displayed in a channel.
-
Tabs are not automatically displayed for the team. To add the tab, select General channel in the team.
-
Select the + icon at the end of the tab strip.
-
In the tab gallery, uploaded tabs are displayed in the Tabs for your team section. Tabs in this section are arranged alphabetically. Select the tab created in this lab.
-
Type a name for the tab. Select Save.
-
The tab is displayed in the channel tab strip.
-
Select the Login to Azure AD button. When the tab is first viewed by a user, the Talent Management application does not have a token to use for calls to the Microsoft Graph. Microsoft Teams will display a popup window which may request login credentials. If a valid token is cached for the user, the popup window will close without user intervention.
-
The tab will display the members of the Azure Active Directory group that supports the Team. Changes to the Team members will be reflected the next time the tab is displayed.