Social Login
Your users already have accounts with Google, GitHub, Discord, and Twitter. Social login lets them use those existing identities to sign into your app with a single click rather than creating yet another set of credentials. The full OAuth dance is handled for you, so the integration boils down to one method call.
How it works
Section titled “How it works”- Your app calls
redirectToSocialLogin("google"), which takes the user to Google’s consent screen - The user grants permission
- Tribe’s server receives the OAuth callback and creates a session
- The user bounces back to your app with a
?tribe_token=parameter in the URL - The SDK detects the token automatically, so
getSession()returns the authenticated user from that point on
Enable social providers
Section titled “Enable social providers”- Go to the Tribe dashboard
- Open your site’s Settings → Auth → Social Login
- Toggle on the providers you want
Check which providers are enabled
Section titled “Check which providers are enabled”It’s good practice to check which providers are active before rendering buttons so your UI stays in sync with your dashboard configuration:
import { Tribe } from "@tribecloud/sdk";
const config = await tribe.getAuthConfig();// config.googleEnabled, config.githubEnabled, config.discordEnabled, config.twitterEnabledAdd social login buttons
Section titled “Add social login buttons”function SocialLoginButtons() { const [config, setConfig] = useState(null);
useEffect(() => { tribe.getAuthConfig().then(setConfig); }, []);
if (!config) return null;
const providers = [ { key: "google", label: "Google", enabled: config.googleEnabled }, { key: "github", label: "GitHub", enabled: config.githubEnabled }, { key: "discord", label: "Discord", enabled: config.discordEnabled }, { key: "twitter", label: "X (Twitter)", enabled: config.twitterEnabled }, ].filter((p) => p.enabled);
return ( <div> {providers.map(({ key, label }) => ( <button key={key} onClick={() => tribe.redirectToSocialLogin(key)}> Continue with {label} </button> ))} </div> );}<div id="social-buttons"></div>
<script src="https://api.tribe.utopian.build/sdk.js?site=YOUR_SITE_ID" defer></script><script defer> window.addEventListener("DOMContentLoaded", async () => { const config = await Tribe.getAuthConfig(); const providers = [ { key: "google", label: "Google", enabled: config.googleEnabled }, { key: "github", label: "GitHub", enabled: config.githubEnabled }, { key: "discord", label: "Discord", enabled: config.discordEnabled }, { key: "twitter", label: "X (Twitter)", enabled: config.twitterEnabled }, ].filter((p) => p.enabled);
const container = document.getElementById("social-buttons"); providers.forEach(({ key, label }) => { const btn = document.createElement("button"); btn.textContent = `Continue with ${label}`; btn.addEventListener("click", () => Tribe.redirectToSocialLogin(key)); container.appendChild(btn); }); });</script>Custom redirect URL
Section titled “Custom redirect URL”After authentication, users normally land back on whichever page initiated the social login. You can point them somewhere else by passing a redirect URL:
tribe.redirectToSocialLogin("google", { redirectUrl: "https://myapp.com/dashboard" });Privacy model
Section titled “Privacy model”Social login is privacy-preserving by design. Rather than storing the user’s real identity from the provider, the server computes a one-way hash from the provider’s user ID:
pseudonymousId = SHA256("google" + ":" + googleUserId + ":" + siteSalt)The actual email and identity from the social provider are never persisted. After social login, a user’s session looks like this:
user.email→nulluser.pseudonymousId→ stable hashed identifieruser.authMethod→"google","github","discord", or"twitter"
- Use
redirectToSocialLogin()directly when you want social login without an intermediate step. Routing through hosted auth pages works too, but it adds an extra redirect that users don’t need. - If you’re already using hosted auth pages, social login buttons appear automatically whenever providers are enabled in the dashboard. No extra code required.
- First-time social login users are registered automatically. There’s no separate sign-up step for them.
- Because pseudonymous users have no email on file, there’s no way to do email-based account recovery. It’s worth prompting them to link a backup auth method right after their first login, so a lost social account doesn’t mean a lost Tribe account.