Listoca
Authentication

Apple and Google

Setting up Sign in with Apple and Google, step by step - the Apple Developer account, Google Cloud, Supabase Auth locally and in production, the app's variables.

Both providers sign in natively in the app. The system's sheet returns an id token, and Supabase Auth turns it into a session (signInWithIdToken, apps/native/src/lib/social-sign-in.ts). So there is no browser round trip, and Supabase only has to know the app's client ids: Apple's is the bundle id, Google's are OAuth clients from Google Cloud.

ProviderWhere it showsNeeds
AppleiOS only, on devices that support itthe capability on the App ID; the bundle id in Supabase
GoogleiOS and Android, once EXPO_PUBLIC_GOOGLE_WEB_CLIENT_ID is seta web, an iOS and Android OAuth clients; their ids in Supabase

The bundle id and Android package are com.listoca.app (apps/native/app.json). Replace example.com below with your domains.

Apple

1. The App ID

In the Apple Developer account → Certificates, Identifiers & Profiles → Identifiers, open the App ID com.listoca.app and turn on Sign In with Apple (as a primary App ID). Save.

app.json already asks for it (ios.usesAppleSignIn, the expo-apple-authentication plugin). When EAS manages the credentials, the first build turns the capability on by itself and makes a new provisioning profile; turning it on by hand first does no harm.

2. Supabase Auth

Supabase checks that the token was issued for one of its Apple client ids.

  • Locally: [auth.external.apple] in supabase/config.toml has client_id = "com.listoca.app". The secret (SUPABASE_AUTH_EXTERNAL_APPLE_SECRET) stays empty: native sign-in doesn't use it.
  • Production: GOTRUE_EXTERNAL_APPLE_CLIENT_ID is com.listoca.app (deploy/supabase/overrides.env.example; on Coolify the variable APPLE_CLIENT_IDS). Leave the secret empty until the web needs it.

3. Try it

Rebuild the app (bun run ios, or an EAS build) and sign in on a device signed in to an Apple Account. The simulator works too once Settings has an Apple Account. Apple sends the name only the first time someone signs in to the app; it fills the profile then. To see that first sign-in again, remove the app under Settings → Apple Account → Sign-In & Security → Sign in with Apple.

Google

In the Google Cloud console, create a project (or pick one), then open Google Auth Platform:

  1. Branding: the app's name, a support email, the logo, and the links https://www.example.com, https://www.example.com/legal/privacy and https://www.example.com/legal/terms. Under Authorized domains, add example.com.
  2. Audience: External. While it is in Testing, only the test users you add can sign in; choose Publish app before the release. Listoca asks only for openid, email and profile, which need no review by Google.
  3. Data Access: add the scopes openid, .../auth/userinfo.email and .../auth/userinfo.profile.

2. The OAuth clients

Google Auth Platform → Clients → Create client, three kinds:

TypeSettingsGives
Web applicationAuthorized redirect URIs: https://api.example.com/auth/v1/callback (and http://127.0.0.1:3041/auth/v1/callback for the local stack)the web client id and its secret
iOSBundle ID com.listoca.appthe iOS client id
AndroidPackage com.listoca.app and one signing certificate's SHA-1an Android client id (one per certificate, see below)

The app asks Google for id tokens on the web client's behalf. Which client id a token carries depends on the platform, so Supabase gets all of them (step 5).

3. The Android certificates

Google signs the app in only when the installed app's signing certificate matches an Android client. Each certificate gets its own client:

  • EAS's keystore, for builds installed outside the Play Store (preview builds, development builds from EAS). eas credentials --platform android → the build profile → the keystore shows its SHA-1. When the Play Store signs the app, this is also the upload key.

  • The Play Store's app signing key, for installs from Google Play. Play Console → the app → Test and release → App integrity → App signing shows its SHA-1, once the first build is uploaded.

  • The debug keystore, for bun run android on your machine. After a prebuild:

    keytool -list -v -keystore apps/native/android/app/debug.keystore -alias androiddebugkey -storepass android -keypass android

The same certificates' SHA-256 values are what VITE_ANDROID_CERT_SHA256 needs for App Links (The app on EAS).

4. The app's variables

VariableValue
EXPO_PUBLIC_GOOGLE_WEB_CLIENT_IDthe web client id
EXPO_PUBLIC_GOOGLE_IOS_CLIENT_IDthe iOS client id

Set them in apps/native/.env for your machine and in every EAS environment (development, preview, production). Without the web client id the app shows no Google button. The iOS client id is read at build time: app.config.ts adds the Google Sign-In plugin with its URL scheme only when it is set, so after setting it, make a new build. The Android client ids don't go into the app; Google matches the package and certificate.

5. Supabase Auth

Supabase accepts a Google token whose audience is one of its Google client ids. List all of them, the web client's first, comma-separated: web, iOS, then each Android client.

  • Locally: SUPABASE_AUTH_EXTERNAL_GOOGLE_CLIENT_ID and SUPABASE_AUTH_EXTERNAL_GOOGLE_SECRET (the web client's secret) in your shell or supabase/.env, then restart the stack.
  • Production: GOTRUE_EXTERNAL_GOOGLE_CLIENT_ID and GOTRUE_EXTERNAL_GOOGLE_SECRET (deploy/supabase/overrides.env.example; on Coolify the variables GOOGLE_CLIENT_IDS and GOOGLE_SECRET).

The nonce check is off for Google, locally (skip_nonce_check = true) and in production (GOTRUE_EXTERNAL_GOOGLE_SKIP_NONCE_CHECK=true). Google's iOS SDK puts a nonce into the id token, and the app has no way to pass that nonce on to Supabase, which would then refuse every sign-in from an iPhone.

6. Try it

Rebuild the app and sign in on iOS and Android. A sign-in that fails on Android only, with DEVELOPER_ERROR, means the installed app's certificate has no Android client yet.

The web

The admin area has no Apple or Google button yet. Locally its admins sign in with the seeded accounts' passwords; production Auth has the email provider off, so there the admin area has no way in until the buttons exist. When it gets them (Supabase's OAuth flow, signInWithOAuth), the providers need their web parts too:

  • Google: nothing more. The web client and its secret are already in Supabase, with the redirect URI https://api.example.com/auth/v1/callback.
  • Apple:
    1. A Services ID (Identifiers → +, e.g. com.listoca.web) with Sign In with Apple on, the domain api.example.com and the return URL https://api.example.com/auth/v1/callback.

    2. A key (Keys → +) with Sign In with Apple, for the App ID. Download the .p8 file (only once) and note its Key ID and your Team ID.

    3. Add the Services ID to the Apple client ids, after the bundle id: com.listoca.app,com.listoca.web.

    4. The secret is a JWT signed with that key, valid for at most six months. Make it with Node:

      node -e '
      const crypto = require("node:crypto"), fs = require("node:fs");
      const [teamId, keyId, servicesId, keyFile] = process.argv.slice(1);
      const part = (value) => Buffer.from(JSON.stringify(value)).toString("base64url");
      const now = Math.floor(Date.now() / 1000);
      const data = part({ alg: "ES256", kid: keyId }) + "." +
        part({ iss: teamId, iat: now, exp: now + 180 * 86400, aud: "https://appleid.apple.com", sub: servicesId });
      const signature = crypto.sign("sha256", Buffer.from(data), { key: fs.readFileSync(keyFile), dsaEncoding: "ieee-p1363" });
      console.log(data + "." + signature.toString("base64url"));
      ' <TEAM_ID> <KEY_ID> com.listoca.web AuthKey_<KEY_ID>.p8

      Put it in GOTRUE_EXTERNAL_APPLE_SECRET (Coolify: APPLE_SECRET), and make a new one before the 180 days run out: with an expired secret, web sign-in with Apple fails while the app's keeps working.

Where the settings live

WhatLocallyProduction
which providers the apps showpackages/auth/src/config.ts (socialProviders)the same
Supabase's providerssupabase/config.tomldeploy/supabase/overrides.env.example, or Coolify step 1
the app's Google client idsapps/native/.envthe EAS environments (The app on EAS)

On this page