Login flow for multiple accessTokens with Microsoft Teams message extension

Copper Contributor

After following the tutorial for Authentication here: https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-authentication?view=azure-bot-service...


I was able to configure 2 OAuth Connection Settings in the Bot Channels Registration

Connection1 : Microsoft Graph using Azure Active Directory v2

Connection 2: 3rd party API using Oauth 2 Generic Provider


From my message extension within the fetchTask handler

use the following code to attempt to get access tokens for both of these Connections

token1 = Context.adaptor.getUserToken(context, connection1)

if no token show auth openURL signin card


token2 = Context.adaptor.getUserToken(context, connection2)

if no token show auth openURL signin card


if both tokens: proceed with logic.


This almost works but will always return undefined for one of the tokens during login or it gets stuck in a loop,  but on subsequent requests it is able to get both tokens from storage successfully.


I noticed some other applications have implemented logging into 2 connections successfully. (Jira)

Can anyone point me in a direction that will help me implement this behavior correctly.


Thank You


1 Reply

Hi @MatthewCohen

It is not possible to utilize two access tokens of two different connections at the same time and you would have to differentiate between the connections based on the requirement/scenario.
Apart from that are you getting any error regarding the connection string configurations? If yes, could you please test the connection over azure.