Auth0, Clerk & Supabase
For sites whose login is run by Auth0, Clerk or Supabase. Your provider stays exactly as it is.
No code: connect your login provider (OIDC)
Customers log in with Auth0, Clerk, Okta or Microsoft Entra External ID? Your portal can use that same login directly. Create an app in your provider, paste three values into Settings, and your portal’s sign-in page shows a “Sign in with …” button. Nothing to install on your website.
Connect your login provider. On Supabase it is in beta and needs a consent page in your app.
Prefer to keep sign-in on your own site? The rest of this page adds one server route that reads your provider’s session instead. It works with Supabase today.
Or add a route: before you start
In GetSupportX, open Settings → Help center & portal → Portal sign-in and switch on Sign in through your website. Answer What is your website built on? with Auth0 · Clerk · Okta · Microsoft.
Under 1 · Secret key, click Create secret key. Copy the key straight away: it is shown once. The code on this page needs it.
Copy the code from 2 · Add the code to your website: your callback URL is already filled in there. Copying the code from this page instead? Replace the whole https://<your-help-center>/portal/handoff address with the Callback URL Settings shows under For developers in step 2. Don’t build it by hand: it isn’t the same for every help center.
Steps
Add your secret key to your server’s environment
As
GSX_SSO_SECRET.Add one route to your app
The Next.js code below, or the Express code if your server is Node.js.
Read the user from your provider
Replace the line that reads the user with your provider’s (below). The route needs a user id that never changes, their email and their name.
Set your sign-in link
The route’s address, for example
https://yourwebsite.com/support.
Reading the user from your provider
The route needs three things from your login: an id that never changes, the email and the name. Send the email only when your provider says it is confirmed; otherwise leave it out, and the id still identifies the customer (why). In a Next.js app, this is where each provider keeps them:
| Provider | Read the signed-in user | Id | Email is confirmed when | Name | |
|---|---|---|---|---|---|
| Clerk | currentUser() from @clerk/nextjs/server | user.id | user.primaryEmailAddress?.emailAddress | user.primaryEmailAddress?.verification?.status === "verified" | user.fullName |
| Auth0 | auth0.getSession() on your Auth0Client from @auth0/nextjs-auth0/server | session.user.sub | session.user.email | session.user.email_verified === true | session.user.name |
| Supabase | supabase.auth.getUser() on a server client made with createServerClient from @supabase/ssr | user.id | user.email | user.email_confirmed_at is set | Whatever your sign-up stores |
Supabase: use getUser(), not getSession()
Supabase warns never to trust getSession() in server code: it reads the login cookie without checking it. Use getUser() (or getClaims(), which Supabase recommends for checks).
In the Next.js code below, replace the getUser import with your provider’s version:
// Replaces: import { getUser } from "@/lib/auth";
import { currentUser } from "@clerk/nextjs/server";
async function getUser() {
const user = await currentUser();
if (!user) return null;
const primary = user.primaryEmailAddress;
// Send the email only once Clerk has verified it. No email: the id still identifies them.
const email = primary?.verification?.status === "verified" ? primary.emailAddress : undefined;
return { id: user.id, email, name: user.fullName };
}// Replaces: import { getUser } from "@/lib/auth";
import { auth0 } from "@/lib/auth0"; // your Auth0Client from @auth0/nextjs-auth0/server
async function getUser() {
const session = await auth0.getSession();
if (!session) return null;
const { user } = session;
// Send the email only once Auth0 says it is verified. No email: the id still identifies them.
const email = user.email_verified === true ? user.email : undefined;
return { id: user.sub, email, name: user.name };
}// Replaces: import { getUser } from "@/lib/auth";
// createClient = your server-side Supabase client (createServerClient from
// @supabase/ssr, set up the way Supabase's Next.js guide shows).
import { createClient } from "@/lib/supabase/server";
async function getUser() {
const supabase = await createClient();
const { data: { user } } = await supabase.auth.getUser();
if (!user) return null;
// Send the email only once Supabase has confirmed it. No email: the id still identifies them.
const email = user.email_confirmed_at ? user.email : undefined;
return { id: user.id, email };
}On an Express server, set user in the Express code from your provider’s middleware the same way: its user id, the email (only when confirmed) and name.
The code
Next.js
// app/support/route.js — Next.js App Router. Your sign-in link: https://yourwebsite.com/support
// Needs GSX_SSO_SECRET in your environment.
import crypto from "node:crypto";
import { getUser } from "@/lib/auth"; // however you read YOUR session
// Your site's address. It keeps customer ids unique if several websites share
// one GetSupportX workspace — set it once and never change it.
const SITE = "https://yourwebsite.com";
const CALLBACK = "https://<your-help-center>/portal/handoff";
// The portal page the customer was heading to (a ticket from an email, say),
// which the portal sends as ?gsx_return=. Only a plain path is passed on —
// GetSupportX checks it again before using it.
function returnPath(value) {
return typeof value === "string" && value.startsWith("/") &&
!value.startsWith("//") && !value.startsWith("/\\") ? value : "";
}
// Signs the customer's details with your SSO secret and sends them to the
// portal. Never cached: the link inside signs one person in.
function signedCallbackUrl(payload, back) {
const secret = process.env.GSX_SSO_SECRET;
if (!secret) throw new Error("GSX_SSO_SECRET is not set — paste your SSO secret into your environment.");
const now = Math.floor(Date.now() / 1000);
// jti: a one-time id, so this exact link can never be used twice.
const body = { ...payload, iat: now, exp: now + 300, jti: crypto.randomBytes(16).toString("hex") };
const b64 = Buffer.from(JSON.stringify(body), "utf8").toString("base64");
const sig = crypto.createHmac("sha256", secret).update(b64).digest("hex");
let url = CALLBACK + "?payload=" + encodeURIComponent(b64) + "&sig=" + sig;
if (returnPath(back)) url += "&redirect=" + encodeURIComponent(back);
return url;
}
function signInRedirect(payload, back) {
return redirectTo(signedCallbackUrl(payload, back));
}
function redirectTo(url) {
return new Response(null, { status: 302, headers: { Location: url, "Cache-Control": "no-store" } });
}
// Taking `request` keeps this route dynamic on every Next.js version.
export async function GET(request) {
const url = new URL(request.url);
const user = await getUser(request);
// Your login page. "next" is this full address, so the customer comes back
// here — and on to the page they wanted — after logging in.
if (!user) return redirectTo(SITE + "/login?next=" + encodeURIComponent(url.pathname + url.search));
return signInRedirect({
externalId: new URL(SITE).host + ":" + user.id,
site: SITE,
legacyExternalId: String(user.id), // keeps customers an older snippet created
email: user.email,
name: user.name,
}, url.searchParams.get("gsx_return"));
}Node.js (Express)
// Express. Your sign-in link: https://yourwebsite.com/support
// Add this to your existing Express app (`app`). Needs GSX_SSO_SECRET in your environment.
import crypto from "node:crypto";
// Your site's address. It keeps customer ids unique if several websites share
// one GetSupportX workspace — set it once and never change it.
const SITE = "https://yourwebsite.com";
const CALLBACK = "https://<your-help-center>/portal/handoff";
// The portal page the customer was heading to (a ticket from an email, say),
// which the portal sends as ?gsx_return=. Only a plain path is passed on —
// GetSupportX checks it again before using it.
function returnPath(value) {
return typeof value === "string" && value.startsWith("/") &&
!value.startsWith("//") && !value.startsWith("/\\") ? value : "";
}
// Signs the customer's details with your SSO secret and sends them to the
// portal. Never cached: the link inside signs one person in.
function signedCallbackUrl(payload, back) {
const secret = process.env.GSX_SSO_SECRET;
if (!secret) throw new Error("GSX_SSO_SECRET is not set — paste your SSO secret into your environment.");
const now = Math.floor(Date.now() / 1000);
// jti: a one-time id, so this exact link can never be used twice.
const body = { ...payload, iat: now, exp: now + 300, jti: crypto.randomBytes(16).toString("hex") };
const b64 = Buffer.from(JSON.stringify(body), "utf8").toString("base64");
const sig = crypto.createHmac("sha256", secret).update(b64).digest("hex");
let url = CALLBACK + "?payload=" + encodeURIComponent(b64) + "&sig=" + sig;
if (returnPath(back)) url += "&redirect=" + encodeURIComponent(back);
return url;
}
function signInRedirect(res, payload, back) {
return redirectTo(res, signedCallbackUrl(payload, back));
}
function redirectTo(res, url) {
res.set("Cache-Control", "no-store");
return res.redirect(302, url);
}
app.get("/support", (req, res) => {
const user = req.user; // however your app stores the session (Passport sets req.user)
// Your login page. "next" is this full address, so the customer comes back
// here — and on to the page they wanted — after logging in.
if (!user) return redirectTo(res, "/login?next=" + encodeURIComponent(req.originalUrl));
return signInRedirect(res, {
externalId: new URL(SITE).host + ":" + user.id,
site: SITE,
legacyExternalId: String(user.id), // keeps customers an older snippet created
email: user.email,
name: user.name,
}, req.query.gsx_return);
});Every version of this code signs the same way. The protocol reference lists each field and rule, including the optional customer details (plan, phone and more) you can add.
Check it works
Save your sign-in link
In Settings → Help center & portal → Portal sign-in, enter it under 3 · Sign-in link (for example
https://yourwebsite.com/support) and click Save. What is the sign-in link?Click Test sign-in
Under Check it works. We open your link as a visitor who isn’t logged in. “Your sign-in link is live” means your link sent that visitor somewhere other than your homepage or the portal, and names the address. Check that address is your login page.
Try it as a customer
Log in to your website, then open your sign-in link. You should land in your portal, signed in. If not, Check it works lists the reason under recent failed sign-ins, and Troubleshooting says how to fix it.
Good to know
- Nothing changes in your Auth0, Clerk or Supabase settings: the route runs on your server, next to your login.
- Send the provider’s user id as the id, not the email. Emails change; ids don’t.
- Only send an email address your provider says is confirmed (the lines below do). Security explains why.
- The provider calls on this page come from their current Next.js SDKs (checked November 2026). If yours is older or newer, look in their docs for how to read the signed-in user on the server. That is the only part that changes.
Read next