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) <noreply@anthropic.com>
This commit is contained in:
Mikael Karlsson
2026-10-10 12:42:44 +11:00
co-authored by Claude Opus 5.5
parent fb819949f5
commit 75c28c83e5
+9
View File
@@ -1513,6 +1513,15 @@ function Start-MSALConsentPrompt
}
[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))