Skip to content

fix(windows): OAuth2 auth flow is broken when opening the browser#61

Open
igormf wants to merge 1 commit intoxdevplatform:mainfrom
igormf:fix/windows-oauth2-flow
Open

fix(windows): OAuth2 auth flow is broken when opening the browser#61
igormf wants to merge 1 commit intoxdevplatform:mainfrom
igormf:fix/windows-oauth2-flow

Conversation

@igormf
Copy link
Copy Markdown

@igormf igormf commented Apr 14, 2026

On Windows, xurl breaks OAuth2 authentication at the very first step because it opens the browser with a truncated authorize URL, so the PKCE flow cannot start correctly.

Summary

  • switch Windows browser launch from cmd /c start to rundll32 url.dll,FileProtocolHandler so the full OAuth2 authorize URL reaches the browser intact
  • honor HOME before os.UserHomeDir() in the token store so home-directory based .xurl lookup and migration behave consistently across environments and tests
  • add a small regression test around browser command construction so the Windows launch path is verified in unit tests

Why this breaks on Windows

The existing Windows path launches the browser via cmd /c start <url>. OAuth2 authorize URLs contain & separators, and cmd treats those as command separators unless they are quoted/escaped in a shell-specific way. In practice, the browser only receives:

https://x.com/i/oauth2/authorize?client_id=...

That strips redirect_uri, response_type, scope, state, code_challenge, and code_challenge_method, so the PKCE flow fails before the user can authenticate.

Test plan

  • go test ./auth ./store
  • unit test verifies the Windows browser-launch command keeps the full OAuth2 PKCE URL as a single argument
  • on Windows, xurl auth oauth2 <username> opens the browser with the full OAuth2 PKCE URL
  • completed OAuth2 authentication successfully on Windows after the browser-launch fix

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 14, 2026

CLA assistant check
All committers have signed the CLA.

@igormf igormf force-pushed the fix/windows-oauth2-flow branch from 6e60616 to 1d88a3c Compare April 14, 2026 16:15
@igormf
Copy link
Copy Markdown
Author

igormf commented Apr 14, 2026

fixes #57

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.

2 participants