Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auth.admin.generateLink doesn't generate PKCE-compatible links #1271

Open
empz opened this issue Sep 14, 2024 · 1 comment
Open

auth.admin.generateLink doesn't generate PKCE-compatible links #1271

empz opened this issue Sep 14, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@empz
Copy link

empz commented Sep 14, 2024

Describe the bug

Trying to generate a PKCE-enabled Magic Link with supabase.auth.admin.generateLink(...) results in a implicit-flow link.

To Reproduce

const email = "[email protected]";

const supabaseAdmin = createClient(
  env.NEXT_PUBLIC_SUPABASE_URL,
  env.SUPABASE_SERVICE_ROLE_KEY,
  { auth: { flowType: "pkce" } },
);

const { data, error } = await supabaseAdmin.auth.admin.generateLink({
  type: "magiclink",
  email,
})

return data.properties.action_link;

Expected behavior

I'd expect this to return a PKCE-flow compatible Magic Link in the shape of:

https://xxxxxxxxxxxxxxx.supabase.co/auth/v1/verify?token=pkce_xxxxxxxxxxxxxx&type=magiclink&redirect_to=http://localhost:3000/api/auth/callback

Just like the regular client sends via email when doing.

    const { data, error} = await supabase.auth.signInWithOtp({
      email,
      options: {
        emailRedirectTo: redirectURL,
      },
    });

But instead, the generateLink admin function generates a non-PKCE token (it doesn't start with pkce_).

System information

  • OS: Irrelevant
  • Browser (if applies): Irrelevant
  • Version of supabase-js: 2.45.4
  • Version of Node.js: 23.13.1
@empz empz added the bug Something isn't working label Sep 14, 2024
@empz
Copy link
Author

empz commented Sep 14, 2024

See this post in the Discord channel for context:
https://discord.com/channels/839993398554656828/1284484812320538787

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant