Skip to content

fix: add localhost HTTP server fallback for OAuth on Linux (#12122)#12123

Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/linux-auth-localhost-callback
Draft

fix: add localhost HTTP server fallback for OAuth on Linux (#12122)#12123
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/linux-auth-localhost-callback

Conversation

@roomote-v0
Copy link
Copy Markdown
Contributor

@roomote-v0 roomote-v0 bot commented Apr 15, 2026

Related GitHub Issue

Closes: #12122

Description

This PR attempts to address Issue #12122 where Linux users (xfce4, some Wayland compositors, and others) cannot complete Roo Cloud authentication because the vscode:// custom URI scheme does not work -- the browser redirect never reaches the extension via handleUri.ts.

The fix: Instead of relying on the vscode:// URI scheme for the OAuth callback, the extension now starts a temporary local HTTP server on http://127.0.0.1:<random-port> and uses that as the auth_redirect parameter. After browser authentication, the Roo Cloud website redirects to this localhost URL, which the extension receives directly -- no custom URI scheme needed.

Key implementation details:

  • LocalAuthServer.ts -- A new class that starts a temporary HTTP server on a random available port, listens for the /auth/clerk/callback endpoint, extracts auth params, responds with a success HTML page, and auto-shuts down.
  • WebAuthService.login() -- Modified to start a LocalAuthServer before opening the browser. The localhost URL is used as auth_redirect. If the server fails to start, it falls back to the original vscode:// URI scheme.
  • WebAuthService.handleCallback() -- Now calls stopLocalAuthServer() on entry to prevent double-processing if both the URI handler and local server fire.
  • The server has a 5-minute timeout and is cleaned up automatically.

Fallback behavior: If the local HTTP server fails to start for any reason, the code falls back to the original vscode:// URI scheme behavior, so this change is backward-compatible.

Feedback and guidance are welcome.

Test Procedure

  • 13 new tests for LocalAuthServer covering: start/stop, callback handling, missing params, timeout, 404 for wrong paths
  • 53 existing WebAuthService tests updated and passing (2 tests updated to reflect the new localhost auth_redirect instead of vscode://)
  • All lint and type-check passes across the monorepo

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue
  • Scope: Changes are focused on the linked issue
  • Self-Review: Performed self-review
  • Testing: New and updated tests added
  • Documentation Impact: No documentation updates required
  • Contribution Guidelines: Read and agree

Documentation Updates

  • No documentation updates are required.

Additional Notes

This approach mirrors what tools like GitHub CLI (gh) and gcloud use for OAuth on environments without custom URI scheme support. The Roo Cloud server needs to accept http://127.0.0.1:PORT as a valid auth_redirect value for this to work end-to-end -- if the server validates/restricts redirect URLs, a server-side allowlist update may be needed.

Interactively review PR in Roo Code Cloud

On Linux desktop environments (e.g., xfce4, some Wayland compositors),
the vscode:// custom URI scheme does not work, preventing the OAuth
callback from reaching the extension after browser authentication.

This adds a LocalAuthServer that starts a temporary HTTP server on
127.0.0.1 with a random port to receive the OAuth callback directly,
bypassing the need for custom URI scheme support.

The server automatically shuts down after receiving the callback or
on timeout (5 minutes). If the local server fails to start, it falls
back to the original vscode:// URI scheme.

Closes #12122
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.

[BUG] Cannot login to Roo Cloud at signup with either vscode or pycharm in linux

2 participants