launcher: refresh Microsoft session before launch #28

Merged
Matt merged 1 commits from feature/launcher-pre-launch-refresh into main 2026-05-23 16:31:18 +00:00
Owner

Stops invalid-session errors after launcher idled >1 hour. Single targeted edit to DoLaunchAsync in MainWindow.axaml.cs. User pulls + builds + deploys from PC (cannot build launcher on glados, Windows SDK required).

Stops invalid-session errors after launcher idled >1 hour. Single targeted edit to DoLaunchAsync in MainWindow.axaml.cs. User pulls + builds + deploys from PC (cannot build launcher on glados, Windows SDK required).
Matt added 1 commit 2026-05-23 16:31:17 +00:00
Microsoft access tokens have a ~1 hour TTL. The launcher cached the
MSession once at sign-in and re-used it on every Play click, so leaving
the launcher open for >1 hour and then hitting Play sent stale
credentials to MC -- Mojang's session check on the server then rejected
the join with "Invalid session".

Fix: in DoLaunchAsync, before assembling the MC launch command, call
_auth.TryAuthenticateSilentlyAsync(). XboxAuthNet's silent flow uses
the cached refresh token (~14 day TTL) to mint a fresh access token
transparently. On success ApplySession swaps in the new MSession and
we launch with valid credentials. On failure (refresh token also
stale) the launcher prompts the player to sign in again -- they keep
the launcher open, hit Sign In, no MC restart needed.

No new dependencies, no UI change beyond the brief "Refreshing
session..." status line, no perf cost beyond the ~500ms HTTP roundtrip
to Microsoft each launch.

Bump the launcher version in launcher/ModpackLauncher.csproj before
publishing so old launcher installs see the upgrade banner.
Matt merged commit 36acbafea5 into main 2026-05-23 16:31:18 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: minecraft/brass-and-sigil#28