When prompting the user for permissions as in screen 1, nothing appears when the user clicks on "Continue".
The code seems to be getting lost somewhere in the OAUTH_PROMPT dialog from Microsoft botbuilder-dialogs.
We already check with someone from validation team and it seems like everything is in order in the Azure portal.
The code is as in the Github sample (bot-conversation-sso-quickstart), as you can see below.
index.js
const {
CloudAdapter,
ConversationState,
MemoryStorage,
UserState,
ConfigurationBotFrameworkAuthentication,
TeamsSSOTokenExchangeMiddleware,
} = require('botbuilder');
const { DialogBot } = require('./bots/dialogBot');
const { MainDialog } = require('./dialogs/mainDialog');
const LANGUAGE_PREFERENCE = 'language_preference';
const botFrameworkAuthentication = new ConfigurationBotFrameworkAuthentication(process.env);
const adapter = new CloudAdapter(botFrameworkAuthentication);
const memoryStorage = new MemoryStorage();
const tokenExchangeMiddleware = new TeamsSSOTokenExchangeMiddleware(memoryStorage, process.env.connectionName);
adapter.use(tokenExchangeMiddleware);
// Create conversation and user state with in-memory storage provider.
const conversationState = new ConversationState(memoryStorage);
const userState = new UserState(memoryStorage);
const languagePreferenceProperty = userState.createProperty(LANGUAGE_PREFERENCE);
const translator = new MicrosoftTranslator(process.env.translatorKey);
adapter.use(new TranslatorMiddleware(translator, languagePreferenceProperty));
const dialog = new MainDialog(userState);
const bot = new DialogBot(process.env.ExpireAfterSeconds, conversationState, userState, dialog, languagePreferenceProperty);
ssoDialog.js
const { ConfirmPrompt, OAuthPrompt, ComponentDialog, DialogSet, DialogTurnStatus, WaterfallDialog } = require('botbuilder-dialogs');
const { SignInDialog, SIGN_IN_DIALOG } = require('./signInDialog');
const { MoniaDialog } = require('./../moniaDialog');
const { polyfills } = require('isomorphic-fetch');
const { CardFactory } = require('botbuilder-core');
const SSO_DIALOG = 'SsoDialog';
const SSO_WATERFALL_DIALOG = 'SsoWaterfallDialog';
const OAUTH_PROMPT = 'OAuthPrompt';
const CONFIRM_PROMPT = 'ConfirmPrompt';
class SsoDialog extends MoniaDialog {
constructor() {
super(SSO_DIALOG, process.env.connectionName);
this.addDialog(new SignInDialog())
this.addDialog(new OAuthPrompt(OAUTH_PROMPT, {
connectionName: process.env.connectionName,
text: 'Please Sign In',
title: 'Sign In',
timeout: 300000
}));
this.addDialog(new ConfirmPrompt(CONFIRM_PROMPT));
this.addDialog(new WaterfallDialog(SSO_WATERFALL_DIALOG, [
this.promptStep.bind(this),
this.oauth.bind(this)
]));
this.initialDialogId = SSO_WATERFALL_DIALOG;
}
async run(context, accessor) {
const dialogSet = new DialogSet(accessor);
dialogSet.add(this);
const dialogContext = await dialogSet.createContext(context);
const results = await dialogContext.continueDialog();
if (results.status === DialogTurnStatus.empty) {
await dialogContext.beginDialog(this.id);
}
}
async promptStep(step) {
try {
return await step.beginDialog(OAUTH_PROMPT);
} catch (err) {
console.error(err);
return await step.endDialog();
}
}
async oauth(step) {
await this.typing(step)
const id = step.context.activity.from.id
const tokenResponse = step.result;
return step.beginDialog(SIGN_IN_DIALOG, tokenResponse)
}
}
module.exports.SsoDialog = SsoDialog;
module.exports.SSO_DIALOG = SSO_DIALOG;
Although, once the user accepts the permissions, for example via teams admin center, they can get a valid token and everything works well.
Do you have any idea for what might be malfunctioning here ?