supabase
supabase copied to clipboard
Google auth integration with Capacitor for IOS
Hello i have the same of this guy https://stackoverflow.com/questions/75671811/supabase-google-auth-integration-with-capacitor-react-for-ios
When i try to signin with google on the browser i don't have any problem, but when i try on mobile, it is opening the browser, is doing the login with google but when redirect on the app again the user is not loogged in.
I have setup my deep linking with capacitor correctly, the problem is that when it redirect on my app after the redirect of google it doesn't keep my session and the user is not logged. This is happening not only for google but also with Github. This is happening only on the app mobile.
This is my code to login:
async function signinGoogle(event) {
event.preventDefault();
try {
await supabase.auth.signInWithOAuth({
provider: "google",
options: {
queryParams: {
access_type: "offline",
prompt: "consent",
},
},
});
} catch (error) {
console.log(error);
}
}
this is in my nuxt config:
modules: ['@nuxtjs/supabase'],
supabase: {
redirect: false,
cookieOptions: {
maxAge: 60 * 60 * 8,
sameSite: 'lax',
secure: true
},
clientOptions: {
auth: {
flowType: 'pkce',
detectSessionInUrl: true,
persistSession: true,
autoRefreshToken: true
},
}
},
and this is the event of capacitor:
App.addListener("appUrlOpen", function (event: URLOpenListenerEvent) {
const router = useRouter();
const slug = event.url.split(".app").pop();
// We only push to the route if there is a slug present
if (slug) {
router.push(slug);
}
});
I followed this: https://capacitorjs.com/docs/guides/deep-links btw as i said is working the deep linking because it is working as expected.
Any help?