[GH-ISSUE #3786] Proposal: choose the Microsoft account at sign-in (needs a localhost redirect URI on the Azure app) #1085

Open
opened 2026-11-02 15:44:09 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @GIGABAIT93 on GitHub (Oct 29, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/3786

🤖 Filed by GIGABAIT93's AI agent (Claude Code, Claude Opus 5.5), not by GIGABAIT93 directly.

Problem

A player with several Microsoft accounts can't choose which one to add to the launcher. Sign-in uses the device code flow, and the code page (www.microsoft.com/link) goes ahead with whatever Microsoft account the browser is already signed in to. To add a second account, the player has to sign out of Microsoft in the browser first, or copy the link into a private window.

Why the launcher can't fix this by itself

  • The device code flow has no option for it. Microsoft's device code reference lists only client_id and scope for the /devicecode request: no prompt, no login_hint, and no verification_uri_complete. The launcher has no way to ask that page for an account picker.

  • Microsoft's documented way is the authorization code flow with PKCE, in the system browser, with prompt=select_account. Microsoft describes that value as one that "interrupts single sign-on providing account selection experience" (auth code reference). The browser then sends the code to a loopback address the launcher listens on.

  • That needs a redirect URI on Horizon's app registration, and today it has none. I opened /authorize for the release build's client ID with each of these redirect URIs. I didn't sign in; the error shows before the sign-in page. Every one got "The provided value for the input parameter 'redirect_uri' is not valid":

    • http://localhost:53682
    • http://127.0.0.1:53682
    • https://login.microsoftonline.com/common/oauth2/nativeclient
    • https://login.live.com/oauth20_desktop.srf

    That's as expected: docs/microsoft-account.md says the device code flow needs no redirect.

Proposal

  1. Ludovic: add one redirect URI to the Horizon app. In the Azure portal: App registrations → Horizon → Authentication → Add a platform → Mobile and desktop applications → custom redirect URI http://localhost.
    • Microsoft ignores the port for localhost redirects (redirect URI rules, "Localhost exceptions"), so the launcher can use any free port.
    • Nothing else changes. "Allow public client flows" stays on, so the device code flow keeps working. The client ID stays the same, so Mojang's approval isn't affected.
  2. Then a launcher PR (account.rs and the sign-in panel; I can write it):
    • Sign in opens the browser at /authorize with PKCE (S256), a random state, prompt=select_account and redirect_uri=http://localhost:<port>.
    • A one-shot listener on loopback takes the code, checks state, and redeems the code at /token with the code_verifier. Xbox Live, XSTS, the Minecraft login and the refresh token stay as they are.
    • The device code flow stays as the fallback: when no loopback port opens, and for account sign-in from a terminal or the MCP server on a machine without a browser.
  3. Until then, launcher only: two options, no Azure change needed for either.
    • A hint in the sign-in panel: "Signed in to a different Microsoft account in your browser? Open the link in a private window."
    • Or an Open in a private window button. The launcher would open the code page in the default browser's private mode, which has no Microsoft session, so the player signs in with the account they choose. This needs the launcher to recognise the default browser and pass its own flag: --incognito for Chrome and Chromium-based browsers, --inprivate for Edge, --private-window for Firefox. For any other browser it falls back to a normal window and the hint.

@ludovic111, would you add the redirect URI in step 1? Once it's there, I'll open the PR for step 2.

Originally created by @GIGABAIT93 on GitHub (Oct 29, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/3786 > 🤖 Filed by GIGABAIT93's AI agent (Claude Code, Claude Opus 5.5), not by GIGABAIT93 directly. ## Problem A player with several Microsoft accounts can't choose which one to add to the launcher. Sign-in uses the device code flow, and the code page (www.microsoft.com/link) goes ahead with whatever Microsoft account the browser is already signed in to. To add a second account, the player has to sign out of Microsoft in the browser first, or copy the link into a private window. ## Why the launcher can't fix this by itself - **The device code flow has no option for it.** Microsoft's [device code reference](https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-device-code) lists only `client_id` and `scope` for the `/devicecode` request: no `prompt`, no `login_hint`, and no `verification_uri_complete`. The launcher has no way to ask that page for an account picker. - **Microsoft's documented way is the authorization code flow with PKCE**, in the system browser, with `prompt=select_account`. Microsoft describes that value as one that "interrupts single sign-on providing account selection experience" ([auth code reference](https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-auth-code-flow)). The browser then sends the code to a loopback address the launcher listens on. - **That needs a redirect URI on Horizon's app registration, and today it has none.** I opened `/authorize` for the release build's client ID with each of these redirect URIs. I didn't sign in; the error shows before the sign-in page. Every one got "The provided value for the input parameter 'redirect_uri' is not valid": - `http://localhost:53682` - `http://127.0.0.1:53682` - `https://login.microsoftonline.com/common/oauth2/nativeclient` - `https://login.live.com/oauth20_desktop.srf` That's as expected: [docs/microsoft-account.md](https://github.com/horizon-rust/horizon/blob/main/docs/microsoft-account.md) says the device code flow needs no redirect. ## Proposal 1. **Ludovic: add one redirect URI** to the Horizon app. In the Azure portal: App registrations → Horizon → Authentication → Add a platform → **Mobile and desktop applications** → custom redirect URI `http://localhost`. - Microsoft ignores the port for localhost redirects ([redirect URI rules, "Localhost exceptions"](https://learn.microsoft.com/en-us/entra/identity-platform/reply-url#localhost-exceptions)), so the launcher can use any free port. - Nothing else changes. "Allow public client flows" stays on, so the device code flow keeps working. The client ID stays the same, so Mojang's approval isn't affected. 2. **Then a launcher PR** (`account.rs` and the sign-in panel; I can write it): - **Sign in** opens the browser at `/authorize` with PKCE (S256), a random `state`, `prompt=select_account` and `redirect_uri=http://localhost:<port>`. - A one-shot listener on loopback takes the code, checks `state`, and redeems the code at `/token` with the `code_verifier`. Xbox Live, XSTS, the Minecraft login and the refresh token stay as they are. - The device code flow stays as the fallback: when no loopback port opens, and for `account sign-in` from a terminal or the MCP server on a machine without a browser. 3. **Until then, launcher only:** two options, no Azure change needed for either. - A hint in the sign-in panel: "Signed in to a different Microsoft account in your browser? Open the link in a private window." - Or an **Open in a private window** button. The launcher would open the code page in the default browser's private mode, which has no Microsoft session, so the player signs in with the account they choose. This needs the launcher to recognise the default browser and pass its own flag: `--incognito` for Chrome and Chromium-based browsers, `--inprivate` for Edge, `--private-window` for Firefox. For any other browser it falls back to a normal window and the hint. @ludovic111, would you add the redirect URI in step 1? Once it's there, I'll open the PR for step 2.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#1085
No description provided.