# Social login providers

> Enable Google, Apple, GitHub, and 19+ sign-in providers, configure Preview and custom-domain redirect URLs, and prevent duplicate-account surprises.

- Canonical: https://exaspark.ai/docs/social-login-setup/

## How OAuth social sign-in works

Social login removes password fatigue. Instead of your app storing a password, a trusted identity provider — such as Google, Apple, or GitHub — confirms the visitor's identity and sends your server a verified sign-in proof.

Every OAuth login runs four quick steps:

- **Redirect to provider.** Clicking **Continue with Google** (or Apple or GitHub) sends the visitor to the provider with your **Client ID** and **redirect URL**.
- **User approves consent.** The visitor signs in and approves sharing basic profile fields (name, avatar, verified email).
- **Callback with one-time code.** The provider redirects back strictly to your allowlisted **redirect (callback) URL** with a short-lived code.
- **Server exchanges code for a session.** Your backend exchanges that code using your private **Client Secret** on the server, loads or creates the user row, and sets an HTTP-only session cookie.

Because code exchange happens strictly on the server, your Client Secret never reaches browser code.

## Picking providers from 19+ supported options

ExaSpark supports **19+ sign-in providers** across consumer, developer, and corporate audiences. Offering two or three familiar choices converts better than a wall of eight buttons and keeps returning customers from accidentally creating duplicate accounts.

| Provider | Best audience | Why users prefer it | Key detail to plan for |
| --- | --- | --- | --- |
| **Google** | Consumer apps, local services, Google Workspace teams | One-tap login across Chrome, Android, and desktop | Publish your OAuth consent screen to **In production** before launch |
| **Apple** | iPhone Safari visitors, consumer apps | Native Face ID / Touch ID sign-in | Supports **Hide My Email** relays; sends name only on first sign-in |
| **GitHub** | Developer tools, technical SaaS | Instant single-click engineering identity | Request `user:email` scope so private GitHub emails still resolve |
| **Microsoft / Entra ID** | Corporate teams and B2B portals | Matches work laptops and Microsoft 365 policies | Ideal for internal tools restricted to a verified company domain |
| **Email + Magic Link** | Universal fallback for every app | Works without any third-party social account | Pair with branded domain sending on launch |

## Configuring redirect URLs for Preview and Live

Most OAuth errors come from one setting: **authorized redirect (callback) URLs**. Providers reject any login whose callback URL does not match their allowlist character for character — including `https://`, subdomain, and trailing slashes.

Because ExaSpark keeps **Preview** and **Live** isolated, register every active origin you use:

```text
ENVIRONMENT          ORIGIN EXAMPLE                    WHEN TO REGISTER
------------------------------------------------------------------------------------
Preview workspace    https://<preview-host>/...        During build & QA
Default Live URL     https://<your-app>.exaspark.app   On initial Publish
Custom Live domain   https://app.yourdomain.com        When connecting a domain

PROVIDER CONSOLE CHECKLIST
  1. Authorized origins:    add every active https:// origin above
  2. Redirect URIs:         paste the exact callback URL from Cloud -> Auth
  3. Policy links:          point to live /privacy and /terms pages
  4. Consent status:        switch from "Testing" to "In production"
```

When you connect a custom domain on Starter or Pro, add its callback URL in your Google, Apple, or GitHub console right after DNS verifies so social login works seamlessly on the new domain. See [Custom domains & DNS](https://exaspark.ai/docs/custom-domains-and-dns/).

## Step-by-step: enabling Google, Apple, or GitHub login

Follow these five steps in order so both Preview testing and your Live launch work on the first click.

1. **Enable your providers in Cloud → Auth** — Open the **Cloud** tab, select the providers you want (for example, Google and Email), and copy the exact callback URLs listed for Preview and Live.
2. **Create OAuth credentials in the provider console** — In Google Cloud Console, Apple Developer, or GitHub Developer Settings, create an OAuth application and paste your exact Preview and Live redirect URLs into the allowlist.
3. **Save Client ID and Client Secret safely** — Enter each provider's Client ID and Client Secret into ExaSpark's provider settings (kept strictly server-side, never pasted into frontend code or public prompts).
4. **Publish the provider consent screen** — In Google Cloud, add your app logo, support email, `/privacy` link, and `/terms` link, then move the OAuth consent screen out of **Testing** mode so real visitors are not blocked.
5. **Test full login loops in Preview and Live** — Sign in with a fresh test account, confirm your profile name and avatar save cleanly, sign out, and sign back in to confirm returning users land in the exact same account.

## Avoiding account-linking and duplicate-account surprises

Customers rarely remember whether they first signed up with email or **Continue with Google**. Thoughtful account-linking rules prevent both accidental duplicate accounts and account-takeover bugs.

### Only auto-link on verified emails

If someone registered `jamie@studio.com` with a password and later clicks **Continue with Google** using that address, merge them strictly when **both sides verify the email**. Never auto-link to an unverified password account — otherwise an attacker could pre-register a victim's email before they ever visit your app.

### Plan for Apple Hide My Email and first-login names

Two Apple Sign-In details surprise builders who skip testing on iPhone:

- **Apple sends `full_name` only once.** Save `full_name` on the user's first sign-in and never overwrite it with `null` on return visits.
- **Hide My Email creates a relay address** (`abc123@privaterelay.appleid.com`). Because that relay will not match an existing Gmail account automatically, provide a **Connected sign-in methods** panel inside Account Settings so signed-in users can view and link providers.

### Protect the user's last sign-in method

Block users from unlinking their final remaining sign-in provider unless they have verified an email password or connected a second provider.

> **Example prompt (App):** Add Google, Apple, and email magic-link sign-in on `/login` and `/signup`. Store the user's name and avatar from the provider on first sign-in without overwriting customized profile fields on later logins. Auto-link social logins to an existing account only when the email is verified on both sides, preserve `?next=` return URLs across the OAuth redirect, and add a "Connected sign-in methods" section in `/settings/account` that displays linked providers and prevents unlinking the user's last sign-in method.

## Troubleshooting OAuth sign-in errors

When a social login button bounces back with an error page, the provider message usually pinpoints the exact configuration mismatch.

| Error or symptom | Most likely cause | How to fix it |
| --- | --- | --- |
| **`Error 400: redirect_uri_mismatch`** | Active domain (Preview, `.exaspark.app`, or custom domain) is missing from the provider's allowed redirect URIs | Copy the exact callback URL from **Cloud → Auth** and add it to your provider console without extra trailing slashes |
| **Google says "Access blocked: app has not completed verification" or caps at 100 users** | Google OAuth consent screen is still in **Testing** mode, or requested sensitive scopes beyond basic profile/email | Request only `openid`, `email`, and `profile` scopes, then publish the consent screen to **In production** |
| **Apple Sign-In user has blank name after second visit** | App tried to read `full_name` on every login instead of saving it on first creation | Persist `full_name` on first sign-in and prompt gracefully in onboarding if a user skipped sharing their name |
| **GitHub login fails with "Email required"** | Developer set their GitHub email to private and app did not fetch verified primary emails | Request the `user:email` scope and select the user's primary verified email from GitHub's email endpoint |
| **Returning customer lands in a brand-new empty account** | User signed up with Google earlier, then clicked Apple (Hide My Email) or a different work email | Show "Last signed in with..." hints where appropriate and let signed-in users link providers in Account Settings |
| **Login succeeds, then immediately drops back to `/login`** | Session cookie mismatch across `http`/`https` or custom domain redirect bounce | Verify your Live app redirects cleanly to one canonical `https://` origin; see [Debugging auth & CORS](https://exaspark.ai/docs/debug-auth-and-cors/) |

> **Note:** **Keep custom-domain cutovers seamless.** Whenever you move a Live app from `.exaspark.app` onto your custom domain, register the custom domain's OAuth callback URL **before** announcing the new link so social sign-ins never break for returning customers.

## Next steps

- [Authentication & roles](https://exaspark.ai/docs/authentication-and-roles/) — Combine 19+ providers with server-enforced Guest, Member, Staff, and Admin roles.
- [Custom domains & DNS](https://exaspark.ai/docs/custom-domains-and-dns/) — Connect your branded domain and update Live callback origins cleanly.
- [Debugging auth & CORS](https://exaspark.ai/docs/debug-auth-and-cors/) — Diagnose stubborn 401 loops, cookie issues, and OAuth callback mismatches.

## From the blog

- [How sign-in works](https://exaspark.ai/blog/how-sign-in-works/) — Clear explanation of OAuth flows, tokens, cookies, and verified emails.
- [App security basics](https://exaspark.ai/blog/app-security-checklist/) — Locking down login flows, secrets, and account linking before launch.
- [User roles and permissions](https://exaspark.ai/blog/user-roles-and-permissions/) — Mapping signed-in accounts cleanly onto Member, Staff, and Admin tiers.
