Skip to content

auth login: show when credentials are being saved, and explain expired codes - #1460

Open
Ben2W wants to merge 2 commits into
planetscale:mainfrom
Ben2W:fix/login-keyring-wait-message
Open

Ben2W wants to merge 2 commits into
planetscale:mainfrom
Ben2W:fix/login-keyring-wait-message

Conversation

@Ben2W

@Ben2W Ben2W commented Oct 4, 2026

Copy link
Copy Markdown

Summary

Two pscale auth login messages make a working login look stuck or broken.

1. "Waiting for confirmation..." stays up after access is approved

After the browser approves the device, login saves the token to the system keyring. On Linux that can block on an unlock prompt, such as GNOME Keyring's password dialog, which may open on another screen or behind other windows. The spinner keeps saying "Waiting for confirmation..." the whole time, so the user keeps looking at the browser step even though it already succeeded. This is the situation in #1132, which was closed when the reporter found the keyring popup, but the CLI output was never changed.

On a machine with a locked login keyring, the keyring's prompter process starts one poll interval after auth login starts. The pscale process then has no connection open to the auth server, and it stays on "Waiting for confirmation..." well past the code's 5-minute expiry.

Once the token arrives, the spinner now changes to:

Access approved. Saving credentials to your system keyring; if it asks to be unlocked, enter your keyring password...

It uses the existing ProgressHandle.Update, the same way metrics report and the D1 import progress do. JSON mode is unchanged.

2. An expired code is reported as a server failure

The token endpoint currently returns the same error_description for every device-flow error, including authorization_pending and expired_token:

{"error":"expired_token","error_description":"The authorization server encountered an unexpected condition which prevented it from fulfilling the request."}

ErrorResponse.Error() returns only the description, so when a confirmation code expires before it's approved, login reports what reads like a server crash. The terminal device-flow errors from RFC 8628 §3.5 are now described from their error codes:

  • expired_token: "the confirmation code expired before it was approved; run 'pscale auth login' again"
  • access_denied: "the login request was denied in the browser"

Other errors still use the server's description. The server's generic error_description for these codes may be worth fixing too.

Testing

  • go build ./..., go vet, staticcheck on the changed packages, and go test ./... all pass.
  • New TestGetAccessTokenForDeviceTerminalErrors covers expired_token and access_denied arriving with the generic description.
  • Reproduced (1) in a pseudo-terminal against a local fake auth server that approves on the third poll. D-Bus was pointed at a nonexistent socket so the CLI used its token-file fallback, and that file was a FIFO, so the save blocks the same way a keyring unlock prompt does. While the save was blocked:
    • before: ⠼ Waiting for confirmation...
    • after: ⠴ Access approved. Saving credentials to your system keyring; if it asks to be unlocked, enter your keyring password...
    • Both print Successfully logged in. once the save completes.

🤖 Generated with Claude Code

Ben2W and others added 2 commits October 4, 2026 14:34
…approval

After the browser approves the device, login saves the token to the
system keyring. That can block on an unlock prompt, such as GNOME
Keyring's password dialog, which may open on another screen. The spinner
kept saying "Waiting for confirmation..." the whole time, so login looked
stuck on the browser step even though access had been approved.

Once the token arrives, the spinner now says access was approved and
that credentials are being saved, and that the keyring may ask to be
unlocked.

See planetscale#1132.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The token endpoint can return the same generic error_description for
every device-flow error, including expired_token: "The authorization
server encountered an unexpected condition which prevented it from
fulfilling the request." When a confirmation code expired before it was
approved, login reported what read like a server failure.

Describe RFC 8628's terminal device-flow errors from their error codes:
an expired code tells the user to run `pscale auth login` again, and a
denied request says it was denied. Other errors still use the server's
description.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Ben2W
Ben2W requested a review from a team as a code owner October 4, 2026 21:35

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant