Skip to content

google login fail #205

@yasyzb

Description

@yasyzb

when I use google login, it redirect_to: http://localhost:5173/auth/callback?code=ad3bcad5-3ab2-4960-873c-b568d404ec6e, then finally to http://localhost:5173/login, without user info.
I debug with src/routes/(marketing)/auth/callback/+server.js, add some console log:

// src/routes/auth/callback/+server.js
import { redirect } from "@sveltejs/kit"
import { isAuthApiError } from "@supabase/supabase-js"

export const GET = async ({ url, locals: { supabase } }) => {
  const code = url.searchParams.get("code")
  if (code) {
    try {
      console.error('session code', code);
      let data = await supabase.auth.exchangeCodeForSession(code)
      console.error('session', data.data);
    } catch (error) {
      // If you open in another browser, need to redirect to login.
      // Should not display error
      if (isAuthApiError(error)) {
        redirect(303, "/login/sign_in?verified=true")
      } else {
        throw error
      }
    }
  }

  const next = url.searchParams.get("next")
  if (next) {
    redirect(303, next)
  }

  redirect(303, "/account")
}

It can log the right session. I am confused.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions