Merge pull request 'launcher: refresh Microsoft session before launch' (#28) from feature/launcher-pre-launch-refresh into main
This commit was merged in pull request #28.
This commit is contained in:
@@ -797,6 +797,32 @@ public partial class MainWindow : Window
|
||||
try
|
||||
{
|
||||
SetBusy(true);
|
||||
|
||||
// ─── Refresh the Microsoft session before launch. ─────────────────
|
||||
// _session was set at sign-in; the access token inside is short-lived
|
||||
// (~1 hour). If the launcher's been open longer than that, MC will
|
||||
// send stale credentials to the server and Mojang's session check
|
||||
// rejects the join ("Invalid session"). XboxAuthNet's silent flow
|
||||
// uses the cached refresh token (~14 day TTL) to mint a fresh
|
||||
// access token transparently.
|
||||
UpdateStatus("Refreshing session...", "");
|
||||
var freshSession = await _auth.TryAuthenticateSilentlyAsync();
|
||||
if (freshSession != null)
|
||||
{
|
||||
ApplySession(freshSession);
|
||||
AppendLog("[auth] Session refreshed before launch.");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Refresh token also stale -- need full interactive re-login.
|
||||
// Don't try inline (player would lose context); prompt them to
|
||||
// hit Sign In again.
|
||||
AppendLog("[auth] Silent refresh returned no session; sign-in required.");
|
||||
UpdateStatus("Session expired", "Please sign in again to continue.");
|
||||
ClearSession();
|
||||
return;
|
||||
}
|
||||
|
||||
var progress = new Progress<ProgressReport>(OnProgress);
|
||||
var installDir = GetInstallDir();
|
||||
_launch ??= new LaunchService(installDir);
|
||||
|
||||
Reference in New Issue
Block a user