[PR #3496] [CLOSED] Launcher: fix sign-in for new accounts, one keychain prompt, Prism-style renewal #5027

Closed
opened 2026-11-03 05:09:42 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3496
Author: @martipops
Created: 10/29/2026
Status: ❌ Closed

Base: main ← Head: auth


📝 Commits (9)

  • 86178bc Launcher: sign in to Minecraft through launcher/login, as the official launcher
  • 856ecf4 Client: the launcher's offline skin (HORIZON_OFFLINE_SKIN)
  • d7aca35 Auth: every account's secrets in one keychain item
  • ffaad31 Auth: renew as Prism and the official launcher do; remember "sign in again"
  • c4d6d18 Auth: account refresh renews a sign-in now
  • 66c6381 Auth: the vault's review: no process writes over another, older items kept
  • 01df74f Auth: the PR review: torn Windows writes, stale open launchers, an undone sign-out
  • e08664c Merge remote-tracking branch 'upstream/main' into auth
  • 66349c6 Skins: the offline look's comments name only the launcher's offline names

📊 Changes

10 files changed (+854 additions, -96 deletions)

View changed files

📝 crates/horizon-client-render/src/skins.rs (+67 -0)
📝 crates/horizon-client/src/game.rs (+15 -0)
📝 crates/horizon-client/src/game/remote.rs (+14 -0)
📝 docs/launcher-commands.md (+10 -0)
📝 docs/microsoft-account.md (+30 -12)
📝 launcher/src/account.rs (+404 -71)
📝 launcher/src/account/tests.rs (+262 -11)
📝 launcher/src/backend.rs (+3 -0)
📝 launcher/src/cli.rs (+22 -1)
📝 launcher/src/main.rs (+27 -1)

📄 Description

🤖 Opened by martipops's AI agent (Claude Code), not by martipops themselves.

Summary

New Microsoft accounts signed in through Horizon's launcher couldn't join any online server. The cause is the endpoint the launcher got its Minecraft token from: it now uses the one the official launcher and Prism use. Around that fix, the sign-in now behaves like Prism's: one keychain prompt instead of several, renewal before the token runs low, and an expired sign-in that says so. The game also finally shows the offline skin the launcher has been handing it.

Before After
A new account joins an online server Refused: "Profile not found" Joins
macOS keychain prompts after a launcher update One per account, per piece One
Token renewed Only in its last hour First use in each launcher run, or under 12 h left
Microsoft refuses the refresh token Retried every launch, played offline Remembered: "Sign in again" in account list and the account's row
Renew by hand No account refresh WHO (MCP account_refresh)
An offline name's skin in the game Default skin Its own skin (third person, arm, tab list)

The sign-in bug, and the evidence

A new account (signed in today in Horizon's launcher) got "Failed to log in: Invalid session" on every online-mode server. The same account joined from the official launcher.

  • Mojang's answer to our client's join (POST sessionserver.mojang.com/session/minecraft/join with that token): ForbiddenOperationException: Profile not found, please restart your launcher if you recently created your profile.
  • The token itself: its claims had no profiles entry at all. An older account's token, issued the same way, had profiles.mc naming its Java profile. The session service only lets a token join as a profile the token names, so the new account's token could never join, although the profile itself existed (GET /minecraft/profile with the same token returned it, with the same ID).
  • Signing out and in again didn't help: a fresh token from authentication/login_with_xbox still had no profile.
  • What the official launcher and Prism do: they get the token from POST https://api.minecraftservices.com/launcher/login with {"xtoken": "XBL3.0 x=<uhs>;<XSTS token>", "platform": "PC_LAUNCHER"}. See Prism's launcher/minecraft/auth/steps/LauncherLoginStep.cpp. The steps before it (Microsoft OAuth, Xbox Live, XSTS for rp://api.minecraftservices.com/) are the same as ours.
  • After the change: signed in again through /launcher/login, the account's token names its profile, Mojang accepts the join, and it plays on an online-mode server.

What players get

  • New accounts can join online servers.
  • On macOS, one keychain prompt after a launcher update, instead of one per account and piece. Verified on a Mac: after the one-time move into the new item, no prompts at all.
  • An expired or revoked sign-in says so: account list marks it (sign in again: …), and the account's row has a Sign in again button. A new sign-in clears the mark.
  • horizon-launcher account refresh WHO (MCP: account_refresh) renews an account's sign-in now, whatever is left on its token, as Prism's Refresh does.
  • An offline name plays with its own skin: third person, the first-person arm and the tab list.

Safety

The keychain change is the part to be careful with, so here is what protects the accounts:

  • Downgrading is safe. Accounts kept the older way (an item per account, <uuid>, <uuid>.1…) are copied into the new item and left in place, so release and older launchers still find them. Signing out removes both.
  • Launchers running at once don't undo each other. The window, the command line and the MCP server can all change accounts. Each change re-reads the item from the keychain, applies only itself and writes it back, under the process's mutex and a lock file every launcher process shares (vault.lock in the launcher's data folder). Test: two_launchers_never_write_over_each_other.
  • An item that doesn't read is never overwritten. It's an error, not an empty account list, and it stays as it was. A failed or refused read is remembered for the run, so there's no prompt loop. Test: a_vault_that_doesnt_read_is_never_written_over.
  • No token is logged or printed. account refresh prints only the account's name. Same keychain service (dev.playhorizon.launcher) and the same access as before; the lock file holds nothing.
  • No keychain reads while the window draws. Which accounts need signing in again is worked out off the UI thread, at start and after Play.

How it's built

Six commits, 10 files, about +570/−40. Launcher account.rs and its tests make up most of it.

# Commit Risk Where to look
1 Sign in through launcher/login Low: endpoint and body only account.rs minecraft_login
2 The game shows the launcher's offline skin Low: isolated client code skins.rs set_local_look, Downloader::offer; game/remote.rs skin resolution; game.rs startup
3 Every account's secrets in one keychain item Review closely account.rs Vault; split_secret now Windows-only
4 Renewal like Prism; "sign in again" remembered Medium account.rs check, RENEW_BEFORE, RENEWED, Secrets::sign_in_again
5 account refresh Low account.rs renew, cli.rs
6 Fixes from an independent review of 3 and 4 Review closely account.rs Vault (re-read and lock on every change, old items kept, unreadable item is an error); main.rs (Msg::SignInAgain); a failed renewal is ignored only with 2 h or more left

Commit 6 comes from a separate review pass over the first five. It found five problems in the keychain and renewal work, all fixed there:

  • two launcher processes could undo each other's sign-ins and sign-outs;
  • migrating deleted the items older launchers still need;
  • a vault that didn't read was treated as empty and saved over;
  • the window read the keychain while drawing;
  • two threads saving at once could leave an older version behind.

docs/microsoft-account.md and docs/launcher-commands.md are updated to match.

New tests in launcher/src/account/tests.rs:

  • renewed_once_each_run_as_prism_does
  • refresh_renews_whatever_is_left
  • every_account_in_one_keychain_item
  • two_launchers_never_write_over_each_other
  • a_vault_that_doesnt_read_is_never_written_over
  • a_launchers_processes_share_the_lock_file
  • long_secrets_split_into_credential_manager_sized_pieces

New test in crates/horizon-client/src/skins.rs:

  • an_offline_skin_is_every_game_s_by_its_uuid

Trying it without risking your own accounts

Point the launcher at a scratch folder, and use an account you don't mind signing in again:

cd launcher
HORIZON_LAUNCHER_HOME=$(mktemp -d) HORIZON_LAUNCHER_NO_SELF_UPDATE=1 cargo run -- account sign-in
HORIZON_LAUNCHER_HOME=… cargo run -- account list
HORIZON_LAUNCHER_HOME=… cargo run -- account refresh <name>

The keychain is still the real one: the new item is shared with your normal launcher. To keep the keychain out of it entirely, set HORIZON_NO_KEYCHAIN=1 (memory only, for the run). A development build needs HORIZON_MSA_CLIENT_ID to sign in.

Overlaps

  • #2937 (Show the signed-in account's own skin in single player and first person) also changes game/remote.rs and skins.rs. This branch handles offline names and #2937 the signed-in account, so they complement each other. Whichever lands second needs a small merge in the skin resolver.
  • #3411 (capes) touches the same two files.
  • This branch follows up #2879 (merged), which split long secrets into pieces, one keychain item each.

Testing

pr_ready (tools/pr_ready.py --base upstream/main on Mac, against upstream/main at e6bb2f74c, 30 min 50 s)

Check Result
Scope ⚠️ 10 files, +570 −40; 562 lines of code: over 500, split it if it can ship in parts; mixes game, launcher
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 408 passed (22 s)
rustfmt ✅ (4 s)
clippy ✅ (1 min 3 s)
tests: horizon-client ✅ 1288 passed (2 min 13 s)
doc tests ✅ 0 passed (31 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ✅
launcher clippy ✅ (37 s)
launcher tests ✅ 252 passed (1 min 2 s)
Parity ❌ 51 affected, 48 passed, failed: block_particles, section_mesh (24 min 53 s)
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

The two parity failures couldn't start on that Mac: its prepared vanilla files lack a client library (netty-transport-native-kqueue-4.2.16.Final-osx-aarch_64.jar, FileNotFoundError before any comparison). They don't compare anything this branch touches; CI's parity job runs them with the full files.

Live checks, on a Mac with two real accounts:

  • New account: refused with "Profile not found" before the change; joins online-mode servers after it.
  • Renewing mid-game: after account refresh, the old token still joins (Mojang accepts both the old and the new one), so a game already running keeps working.
  • Keychain prompts: one-time move into the new item (one prompt per old piece), then no prompts at all.

Known limits and open points

  • Unapproved app IDs, untested. With login_with_xbox, an app Mojang hasn't approved got HTTP 403 ("Invalid app registration"), which the launcher shows as "its app is not approved by Mojang yet". I couldn't check whether /launcher/login refuses an unapproved app the same way: Horizon's app ID is approved. Official builds aren't affected. A build with its own unapproved ID might see the generic "refused the sign-in" instead. Someone with an unapproved ID could confirm it in a minute.
  • "Never renew while in a game" is left out. Prism has this rule. The launcher doesn't track running games, and a renewal was shown not to invalidate the token a running game holds.
  • Windows writes the vault in pieces. Credential Manager's per-item limit means the vault is still several pieces (vault, vault.1…), written one after another. A write torn halfway reads back as an error, never as an empty vault, so no account is lost; it could still need a sign-in again.
  • The lock file is best-effort. It locks only where File::lock works, and is skipped quietly if the file can't be opened. The process's mutex still orders changes within one process.
  • Size. About 610 changed lines, a little over the ~500-line guideline. The commits are separable if a split is preferred, for example the offline skin (commit 2) as its own PR.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/3496 **Author:** [@martipops](https://github.com/martipops) **Created:** 10/29/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `auth` --- ### 📝 Commits (9) - [`86178bc`](https://github.com/horizon-rust/horizon/commit/86178bc6940b3d089d0e8d1a96aeb0bd1b3d6660) Launcher: sign in to Minecraft through launcher/login, as the official launcher - [`856ecf4`](https://github.com/horizon-rust/horizon/commit/856ecf4671995d0c667489e2ec2e001245fdf2ab) Client: the launcher's offline skin (HORIZON_OFFLINE_SKIN) - [`d7aca35`](https://github.com/horizon-rust/horizon/commit/d7aca35189491bf2af31b6b9ade4c0976aba07b5) Auth: every account's secrets in one keychain item - [`ffaad31`](https://github.com/horizon-rust/horizon/commit/ffaad31190c5098fd0e38ee969600b22e0ab374d) Auth: renew as Prism and the official launcher do; remember "sign in again" - [`c4d6d18`](https://github.com/horizon-rust/horizon/commit/c4d6d18ce78ee0366fa9a68673f40dbae1966d42) Auth: account refresh renews a sign-in now - [`66c6381`](https://github.com/horizon-rust/horizon/commit/66c638131fc54d743be0b71c6641ad164ae44ec3) Auth: the vault's review: no process writes over another, older items kept - [`01df74f`](https://github.com/horizon-rust/horizon/commit/01df74f9d8cfe8378852121ac0c08d17fdecc969) Auth: the PR review: torn Windows writes, stale open launchers, an undone sign-out - [`e08664c`](https://github.com/horizon-rust/horizon/commit/e08664cc9cb54c21c281c83baa6c42cbadbffbce) Merge remote-tracking branch 'upstream/main' into auth - [`66349c6`](https://github.com/horizon-rust/horizon/commit/66349c6986676d2c3aefb8321d593b995c8357f7) Skins: the offline look's comments name only the launcher's offline names ### 📊 Changes **10 files changed** (+854 additions, -96 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/skins.rs` (+67 -0) 📝 `crates/horizon-client/src/game.rs` (+15 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+14 -0) 📝 `docs/launcher-commands.md` (+10 -0) 📝 `docs/microsoft-account.md` (+30 -12) 📝 `launcher/src/account.rs` (+404 -71) 📝 `launcher/src/account/tests.rs` (+262 -11) 📝 `launcher/src/backend.rs` (+3 -0) 📝 `launcher/src/cli.rs` (+22 -1) 📝 `launcher/src/main.rs` (+27 -1) </details> ### 📄 Description > 🤖 Opened by martipops's AI agent (Claude Code), not by martipops themselves. ## Summary New Microsoft accounts signed in through Horizon's launcher couldn't join any online server. The cause is the endpoint the launcher got its Minecraft token from: it now uses the one the official launcher and Prism use. Around that fix, the sign-in now behaves like Prism's: one keychain prompt instead of several, renewal before the token runs low, and an expired sign-in that says so. The game also finally shows the offline skin the launcher has been handing it. | | Before | After | |---|---|---| | A new account joins an online server | Refused: "Profile not found" | Joins | | macOS keychain prompts after a launcher update | One per account, per piece | One | | Token renewed | Only in its last hour | First use in each launcher run, or under 12 h left | | Microsoft refuses the refresh token | Retried every launch, played offline | Remembered: "Sign in again" in `account list` and the account's row | | Renew by hand | No | `account refresh WHO` (MCP `account_refresh`) | | An offline name's skin in the game | Default skin | Its own skin (third person, arm, tab list) | ## The sign-in bug, and the evidence A new account (signed in today in Horizon's launcher) got "Failed to log in: Invalid session" on every online-mode server. The same account joined from the official launcher. - **Mojang's answer to our client's join** (`POST sessionserver.mojang.com/session/minecraft/join` with that token): `ForbiddenOperationException: Profile not found, please restart your launcher if you recently created your profile`. - **The token itself:** its claims had no `profiles` entry at all. An older account's token, issued the same way, had `profiles.mc` naming its Java profile. The session service only lets a token join as a profile the token names, so the new account's token could never join, although the profile itself existed (`GET /minecraft/profile` with the same token returned it, with the same ID). - **Signing out and in again didn't help:** a fresh token from `authentication/login_with_xbox` still had no profile. - **What the official launcher and Prism do:** they get the token from `POST https://api.minecraftservices.com/launcher/login` with `{"xtoken": "XBL3.0 x=<uhs>;<XSTS token>", "platform": "PC_LAUNCHER"}`. See Prism's `launcher/minecraft/auth/steps/LauncherLoginStep.cpp`. The steps before it (Microsoft OAuth, Xbox Live, XSTS for `rp://api.minecraftservices.com/`) are the same as ours. - **After the change:** signed in again through `/launcher/login`, the account's token names its profile, Mojang accepts the join, and it plays on an online-mode server. ## What players get - New accounts can join online servers. - On macOS, one keychain prompt after a launcher update, instead of one per account and piece. Verified on a Mac: after the one-time move into the new item, no prompts at all. - An expired or revoked sign-in says so: `account list` marks it `(sign in again: …)`, and the account's row has a **Sign in again** button. A new sign-in clears the mark. - `horizon-launcher account refresh WHO` (MCP: `account_refresh`) renews an account's sign-in now, whatever is left on its token, as Prism's Refresh does. - An offline name plays with its own skin: third person, the first-person arm and the tab list. ## Safety The keychain change is the part to be careful with, so here is what protects the accounts: - **Downgrading is safe.** Accounts kept the older way (an item per account, `<uuid>`, `<uuid>.1`…) are copied into the new item and **left in place**, so release and older launchers still find them. Signing out removes both. - **Launchers running at once don't undo each other.** The window, the command line and the MCP server can all change accounts. Each change re-reads the item from the keychain, applies only itself and writes it back, under the process's mutex and a lock file every launcher process shares (`vault.lock` in the launcher's data folder). Test: `two_launchers_never_write_over_each_other`. - **An item that doesn't read is never overwritten.** It's an error, not an empty account list, and it stays as it was. A failed or refused read is remembered for the run, so there's no prompt loop. Test: `a_vault_that_doesnt_read_is_never_written_over`. - **No token is logged or printed.** `account refresh` prints only the account's name. Same keychain service (`dev.playhorizon.launcher`) and the same access as before; the lock file holds nothing. - **No keychain reads while the window draws.** Which accounts need signing in again is worked out off the UI thread, at start and after Play. ## How it's built Six commits, 10 files, about +570/−40. Launcher `account.rs` and its tests make up most of it. | # | Commit | Risk | Where to look | |---|---|---|---| | 1 | Sign in through `launcher/login` | Low: endpoint and body only | `account.rs` `minecraft_login` | | 2 | The game shows the launcher's offline skin | Low: isolated client code | `skins.rs` `set_local_look`, `Downloader::offer`; `game/remote.rs` skin resolution; `game.rs` startup | | 3 | Every account's secrets in one keychain item | **Review closely** | `account.rs` `Vault`; `split_secret` now Windows-only | | 4 | Renewal like Prism; "sign in again" remembered | Medium | `account.rs` `check`, `RENEW_BEFORE`, `RENEWED`, `Secrets::sign_in_again` | | 5 | `account refresh` | Low | `account.rs` `renew`, `cli.rs` | | 6 | Fixes from an independent review of 3 and 4 | **Review closely** | `account.rs` `Vault` (re-read and lock on every change, old items kept, unreadable item is an error); `main.rs` (`Msg::SignInAgain`); a failed renewal is ignored only with 2 h or more left | Commit 6 comes from a separate review pass over the first five. It found five problems in the keychain and renewal work, all fixed there: - two launcher processes could undo each other's sign-ins and sign-outs; - migrating deleted the items older launchers still need; - a vault that didn't read was treated as empty and saved over; - the window read the keychain while drawing; - two threads saving at once could leave an older version behind. `docs/microsoft-account.md` and `docs/launcher-commands.md` are updated to match. New tests in `launcher/src/account/tests.rs`: - `renewed_once_each_run_as_prism_does` - `refresh_renews_whatever_is_left` - `every_account_in_one_keychain_item` - `two_launchers_never_write_over_each_other` - `a_vault_that_doesnt_read_is_never_written_over` - `a_launchers_processes_share_the_lock_file` - `long_secrets_split_into_credential_manager_sized_pieces` New test in `crates/horizon-client/src/skins.rs`: - `an_offline_skin_is_every_game_s_by_its_uuid` ### Trying it without risking your own accounts Point the launcher at a scratch folder, and use an account you don't mind signing in again: ```sh cd launcher HORIZON_LAUNCHER_HOME=$(mktemp -d) HORIZON_LAUNCHER_NO_SELF_UPDATE=1 cargo run -- account sign-in HORIZON_LAUNCHER_HOME=… cargo run -- account list HORIZON_LAUNCHER_HOME=… cargo run -- account refresh <name> ``` The keychain is still the real one: the new item is shared with your normal launcher. To keep the keychain out of it entirely, set `HORIZON_NO_KEYCHAIN=1` (memory only, for the run). A development build needs `HORIZON_MSA_CLIENT_ID` to sign in. ## Overlaps - **#2937** (Show the signed-in account's own skin in single player and first person) also changes `game/remote.rs` and `skins.rs`. This branch handles offline names and #2937 the signed-in account, so they complement each other. Whichever lands second needs a small merge in the skin resolver. - **#3411** (capes) touches the same two files. - This branch follows up #2879 (merged), which split long secrets into pieces, one keychain item each. ## Testing **pr_ready** (`tools/pr_ready.py --base upstream/main` on Mac, against upstream/main at e6bb2f74c, 30 min 50 s) | Check | Result | | --- | --- | | Scope | ⚠️ 10 files, +570 −40; 562 lines of code: over 500, split it if it can ship in parts; mixes game, launcher | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 408 passed (22 s) | | rustfmt | ✅ (4 s) | | clippy | ✅ (1 min 3 s) | | tests: horizon-client | ✅ 1288 passed (2 min 13 s) | | doc tests | ✅ 0 passed (31 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ✅ | | launcher clippy | ✅ (37 s) | | launcher tests | ✅ 252 passed (1 min 2 s) | | Parity | ❌ 51 affected, 48 passed, failed: block_particles, section_mesh (24 min 53 s) | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | The two parity failures couldn't start on that Mac: its prepared vanilla files lack a client library (`netty-transport-native-kqueue-4.2.16.Final-osx-aarch_64.jar`, `FileNotFoundError` before any comparison). They don't compare anything this branch touches; CI's parity job runs them with the full files. Live checks, on a Mac with two real accounts: - **New account:** refused with "Profile not found" before the change; joins online-mode servers after it. - **Renewing mid-game:** after `account refresh`, the old token still joins (Mojang accepts both the old and the new one), so a game already running keeps working. - **Keychain prompts:** one-time move into the new item (one prompt per old piece), then no prompts at all. ## Known limits and open points - **Unapproved app IDs, untested.** With `login_with_xbox`, an app Mojang hasn't approved got HTTP 403 ("Invalid app registration"), which the launcher shows as "its app is not approved by Mojang yet". I couldn't check whether `/launcher/login` refuses an unapproved app the same way: Horizon's app ID is approved. Official builds aren't affected. A build with its own unapproved ID might see the generic "refused the sign-in" instead. Someone with an unapproved ID could confirm it in a minute. - **"Never renew while in a game" is left out.** Prism has this rule. The launcher doesn't track running games, and a renewal was shown not to invalidate the token a running game holds. - **Windows writes the vault in pieces.** Credential Manager's per-item limit means the vault is still several pieces (`vault`, `vault.1`…), written one after another. A write torn halfway reads back as an error, never as an empty vault, so no account is lost; it could still need a sign-in again. - **The lock file is best-effort.** It locks only where `File::lock` works, and is skipped quietly if the file can't be opened. The process's mutex still orders changes within one process. - **Size.** About 610 changed lines, a little over the ~500-line guideline. The commits are separable if a split is preferred, for example the offline skin (commit 2) as its own PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:09:42 +07:00
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#5027
No description provided.