SupabaseS
Supabase6mo ago
DizoR

Supabase Auth, get a code instead of session

Hello everybody,

I'm using Supbase DB et Auth with Nextjs (front) and Nestjs (back)

My case is I symply log with google
      const { error } = await supabase.auth.signInWithOAuth({
        provider,
        options: {
          redirectTo: `${window.location.origin}/auth/callback`,
        },
      });


And and get the response in a callback
export default function AuthCallback() {
  const router = useRouter();
  const cookies = useCookies();

  useEffect(() => {
    const handleAuthCallback = async () => {
      try {
        // Get the session from the URL hash
        const { data, error } = await supabase.auth.getSession();


It's working fine ... but I found this function supabase.auth.exchangeCodeForSession(String(code))

Which is better because I would like to get the code in the fronted and get the JWT in the backend, and share only few fields encrypted (more safe)

So the callback url contains the entire session
Is there a solution to change it to a code instead ?
Was this page helpful?