Skip to content

prepPKCERedirectURLdrops // from custom scheme URIs, corrupting PKCE auth code on iOS (%23) #2423

@rintaro-okahara

Description

@rintaro-okahara

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

When using PKCE OAuth from on iOS with a custom URL scheme that has no path (ex. myapp://), the redirect URL returned to the app contains a corrupted auth code a trailing %23 (URL-encoded #). This causes exchangeCode ForSession to fail with "No valid flow state found".

To Reproduce

  1. Create an Expo React Native app targeting iOS
  2. Use makeRedirectUri() with no arguments → returns myapp://
  3. Call supabase.auth.signInWithOAuth({ provider: 'google', options: { redirectTo: 'myapp://', skipBrowserRedirect: true } })
  4. Open the auth URL with WebBrowser.openAuthSessionAsync
  5. Complete Google sign-in
  6. Observe result.url contains myapp:?code=CODE%23 instead of myapp://?code=CODE
  7. exchangeCodeForSession fails with "No valid flow state found"

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: [e.g. macOS, Windows]
  • Browser (if applies) [e.g. chrome, safari]
  • Version of supabase-js: [e.g. 6.0.2]
  • Version of Node.js: [e.g. 10.10.0]

Additional context

Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions