Skip to content

Conversation

@JonZa
Copy link

@JonZa JonZa commented Jan 2, 2026

Summary

The X OAuth handler was generating new PKCE values on every request via inline randomUUID() calls in the config defaults. This caused the token exchange to fail because the code_verifier didn't match the original code_challenge.

Changes:

  • Use handlePkceVerifier utility to persist verifier in cookie
  • Use S256 challenge method instead of plain (more secure)
  • Add proper state validation using handleState/handleInvalidState
  • Remove broken inline PKCE/state generation from authorizationParams
  • Ensure PKCE/state values can't be overridden by user config (spread authorizationParams before setting secure values)

Test plan

  • Complete X OAuth flow end-to-end
  • Verify nuxt-auth-pkce cookie is set on redirect and cleared on callback
  • Verify nuxt-auth-state cookie is set on redirect and cleared on callback
  • Test retry after user cancellation
  • Verify custom authorizationParams (e.g., prompt) still work

The X OAuth handler was generating new PKCE values on every request via
inline randomUUID() calls in the config defaults. This caused the token
exchange to fail because the code_verifier didn't match the original
code_challenge.

This fix:
- Uses handlePkceVerifier utility to persist verifier in cookie
- Uses S256 challenge method instead of plain (more secure)
- Adds proper state validation using handleState/handleInvalidState
- Removes broken inline PKCE/state generation from authorizationParams
- Ensures PKCE/state values can't be overridden by user config
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