Skip to content

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

Merged
santiagomed merged 2 commits intoxdevplatform:mainfrom
igormf:fix/windows-oauth2-flow
Apr 19, 2026
Merged

fix(windows): OAuth2 auth flow is broken when opening the browser#61
santiagomed merged 2 commits intoxdevplatform:mainfrom
igormf:fix/windows-oauth2-flow

Conversation

@igormf
Copy link
Copy Markdown
Contributor

@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
Contributor Author

igormf commented Apr 14, 2026

fixes #57

Copy link
Copy Markdown
Collaborator

@santiagomed santiagomed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix, @igormf!

@santiagomed santiagomed merged commit 3264654 into xdevplatform:main Apr 19, 2026
2 checks passed
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.

3 participants