github / github/app

WAM interactive browser auth stops working mid-session when running PowerShell scripts via background terminal

Offen
#1,801 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Bugs
Vorherrschende Sprache
Keine Sprachdaten
Sterne
2.1k
Forks
153
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Short summary
PowerShell scripts using Connect-MgGraph (Microsoft Graph SDK) authenticate successfully via WAM on first run, but fail with "A window handle must be configured" later in the same session after terminal canvas panels are opened/closed.

Affected version or release
Latest (updated 2026-07-09)

Installation context
Windows desktop app, background terminal used to run PowerShell scripts via agent session

What happened?
When running PowerShell scripts that call Connect-MgGraph with interactive browser auth via the Copilot app background terminal, WAM authentication worked correctly on first run. Later in the same session — after opening and closing terminal canvas panels — the same scripts started failing immediately with:

InteractiveBrowserCredential authentication failed: A window handle must be configured.
See https://aka.ms/msal-net-wam#parent-window-handles

The WAM browser prompt no longer appears at all; it fails without waiting for user interaction. The background PowerShell process appears to lose its window handle mid-session, likely caused by terminal canvas lifecycle events. Workaround is to use -UseDeviceCode on Connect-MgGraph, but interactive browser auth should remain stable throughout a session.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start by reproducing the issue with Connect-MgGraph in the background PowerShell terminal, then open and close terminal canvas panels before retrying interactive browser authentication. Investigate how the background terminal and terminal canvas lifecycle preserve the WAM window handle. Done means interactive browser authentication continues to show its prompt and succeeds throughout the session without requiring -UseDeviceCode.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
powershell
Bereich
authentication, desktop
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.