Supabase server client OAuth methods not working
Unanswered
American Pipit posted this in #help-forum
American PipitOP
export const signUpWithGoogle = async () => {
'use server';
const cookieStore = cookies();
const serverSupabase = createServerClient<Database>(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
{
cookies: {
get(name: string) {
return cookieStore.get(name)?.value;
},
set(name: string, value: string, options: CookieOptions) {
cookieStore.set({ name, value, ...options });
},
remove(name: string, options: CookieOptions) {
cookieStore.delete({ name, ...options });
},
},
}
);
const {data, error} = await serverSupabase.auth.signInWithOAuth({
provider: 'google',
options: { redirectTo: `${getURL()}/auth/callback` },
});
};
this is my server action, most of the other auth stuff is from the supabase docs. When I log
data
, it shows {url: someUrl, provider: google}
, and when I manually go to that URL, it's actually the google sign in the function should redirect the user to.1 Reply
Korat
if (data.url) {
redirect(data.url)
}
Add this after you get data from signInWithOAuth. You'll get the URL that you need to use to redirect to the consent screen for Google.