supabase icon indicating copy to clipboard operation
supabase copied to clipboard

No session created when working with 0Auth Clients

Open Acentrix-Jordan opened this issue 1 year ago • 5 comments

Version

@nuxtjs/supabase:v1.0.2 nuxt: v3.4.3

Reproduction Link

No link as I have downgraded the Supabase module down to 0.3.0 as per the tutorial I am following.

Steps to reproduce

  1. Create a project
  2. Add Google or Github OAuth authentication
  3. On the login.vue page try firing the function below
const supabase = useSupabaseClient();

const login = async () => {
	const { error } = await supabase.auth.signInWithOAuth({
		provider: "google",
	});

	if (error) {
		console.error(error);
	}
};

What is Expected?

The user is directed to the third party OAuth, performs authentication and then redirected to the application where a session is created.

What is actually happening?

We are successfully redirected to google/github to confirm auth, however when we get redirected back our app, no session is created.

The auth is tracked in supabase and the user is added but no google authentication has been tracked in google. (As if the request was never sent)

Acentrix-Jordan avatar Aug 29 '23 18:08 Acentrix-Jordan

Same

SaulAbreu avatar Aug 31 '23 22:08 SaulAbreu

So after troubleshooting for a few minutes, I found that the issue seems to be related to the missing redirectTo option in the parameters:

options: {
      redirectTo: 'http://localhost:3000/confirm',
    },

Adding this option fixed the issue. However, I am not sure why it was causing problems in the first place. It seems that the URL configuration was being completely ignored.

tomasmorello avatar Sep 13 '23 04:09 tomasmorello

So after troubleshooting for a few minutes, I found that the issue seems to be related to the missing redirectTo option in the parameters:

options: {
      redirectTo: 'http://localhost:3000/confirm',
    },

Adding this option fixed the issue. However, I am not sure why it was causing problems in the first place. It seems that the URL configuration was being completely ignored.

Should this work without creating a /confirm page or it need to exists? I mean, could the /confirm page be the same as the login?

negativems avatar Sep 18 '23 06:09 negativems

So after troubleshooting for a few minutes, I found that the issue seems to be related to the missing redirectTo option in the parameters:

options: {
      redirectTo: 'http://localhost:3000/confirm',
    },

Adding this option fixed the issue. However, I am not sure why it was causing problems in the first place. It seems that the URL configuration was being completely ignored.

Should this work without creating a /confirm page or it need to exists? I mean, could the /confirm page be the same as the login?

I think it can't, but I would give it a try. Im afraid that could bring you an unexpected behavior sooner or later.

tomasmorello avatar Sep 18 '23 09:09 tomasmorello

I disabled ssr for the confirm page in nuxt.config.js and it works for me now.

routeRules: {
    "/confirm": { ssr: false },
},

felipemarcos avatar Jul 20 '24 10:07 felipemarcos