From f95b35bf2ac1330c7250abc0f0d62a075022c48e Mon Sep 17 00:00:00 2001 From: David Date: Tue, 19 Mar 2024 04:27:25 -0400 Subject: [PATCH] Added info about signInWithOauth redirect (#22088) Co-authored-by: Charis Lam <26616127+charislam@users.noreply.github.com> --- .../oauth-with-pkce-flow-for-ssr.mdx | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/apps/docs/content/guides/auth/server-side/oauth-with-pkce-flow-for-ssr.mdx b/apps/docs/content/guides/auth/server-side/oauth-with-pkce-flow-for-ssr.mdx index 9ff80b227e0..bc69e411514 100644 --- a/apps/docs/content/guides/auth/server-side/oauth-with-pkce-flow-for-ssr.mdx +++ b/apps/docs/content/guides/auth/server-side/oauth-with-pkce-flow-for-ssr.mdx @@ -207,6 +207,17 @@ app.get("/auth/callback", async function (req, res) { Let's point our `.signInWithOAuth` method's redirect to the callback route we create above: + + + +In the browser, `signInWithOAuth` automatically redirects to the SSO provider's authentication endpoint, which then redirects to your endpoint. + ```js await supabase.auth.signInWithOAuth({ provider, @@ -215,3 +226,26 @@ await supabase.auth.signInWithOAuth({ }, }) ``` + + + + + +In the server, you need to handle the redirect to the SSO provider's authentication endpoint. The `signInWithOAuth` method returns the endpoint URL, which you can redirect to. + +```js +const { data, error } = await supabase.auth.signInWithOAuth({ + provider, + options: { + redirectTo: '/auth/callback', + }, +}) + +if (data.url) { + redirect(data.url) // use the redirect API for your server framework +} +``` + + + +