From 1c6b56a67f0820e78098abfb526f7d71e0023021 Mon Sep 17 00:00:00 2001 From: Andris Reinman Date: Mon, 11 Dec 2023 13:57:38 +0200 Subject: [PATCH] fix(oauth2-outlook): Enforce account selection when authenticating OAuth2 connections for MS365 --- lib/oauth/outlook.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/oauth/outlook.js b/lib/oauth/outlook.js index e5143c4fe..862c60fa1 100644 --- a/lib/oauth/outlook.js +++ b/lib/oauth/outlook.js @@ -87,11 +87,18 @@ class OutlookOauth { opts = opts || {}; const url = new URL(`https://login.microsoftonline.com/${this.authority}/oauth2/v2.0/authorize`); + url.searchParams.set('client_id', this.clientId); url.searchParams.set('response_type', 'code'); url.searchParams.set('redirect_uri', this.redirectUrl); url.searchParams.set('response_mode', 'query'); url.searchParams.set('client_info', '1'); + url.searchParams.set('prompt', 'select_account'); + + if (opts.email) { + url.searchParams.set('login_hint', opts.email); + } + url.searchParams.set('scope', this.scopes.join(' ')); if (opts.state) {