From 75c28c83e54ad248971b24ef4013b4141d32a4e7 Mon Sep 17 00:00:00 2001 From: Mikael Karlsson <43226266+Micke-K@users.noreply.github.com> Date: Sat, 10 Oct 2026 12:42:44 +1100 Subject: [PATCH] Consent prompt: honour "Use System Browser for login" Start-MSALConsentPrompt built its own interactive request without the WithUseEmbeddedWebView($false) that Connect-MSALUser applies when the setting is on, so Request Consent opened the embedded window: no access to the browser session (it asked for a new sign-in) and no passkey / FIDO2 support. It now makes the same browser choice as the login. Reported in discussion #439. Co-Authored-By: Claude Opus 5.5 (1M context) --- Extensions/MSALAuthentication.psm1 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Extensions/MSALAuthentication.psm1 b/Extensions/MSALAuthentication.psm1 index e9d3e32..6ce0d33 100644 --- a/Extensions/MSALAuthentication.psm1 +++ b/Extensions/MSALAuthentication.psm1 @@ -1512,6 +1512,15 @@ function Start-MSALConsentPrompt [void]$aquireTokenObj.WithParentActivityOrWindow($ParentWindow) } [void]$aquireTokenObj.WithPrompt([Microsoft.Identity.Client.Prompt]::NoPrompt) + + # Same browser choice as the login (Connect-MSALUser): without this the consent + # prompt fell back to the embedded window, which has no access to the browser + # session (so it asked for a new sign-in) and cannot use passkeys or FIDO2 keys. + if($script:MSALUseSystemBrowser) + { + try { [void]$aquireTokenObj.WithUseEmbeddedWebView($false) } + catch { Write-LogDebug "WithUseEmbeddedWebView unavailable: $($_.Exception.Message)" } + } Write-Log "Consent prompt for the following scopes: $(($script:missingPermissions -join ","))" [void] $aquireTokenObj.WithExtraScopesToConsent(([string[]]$script:missingPermissions))