Skip to main content
The Soundcheck mobile app uses Clerk for authentication, supporting email/password, Google OAuth, and Apple Sign In on supported platforms (not every SSO option appears on every platform).

Overview

Authentication is handled through:
  • Clerk SDK for session management
  • JWT tokens for API authentication
  • SecureStore for token persistence
  • OAuth flows for social login

Authentication methods

Email/password

Traditional email and password authentication with:
  • Email verification
  • Password reset flow
  • Session management

Google OAuth

“Continue with Google” runs useGoogleSsoFlow (lib/hooks/useGoogleSsoFlow.ts), which picks one of two flows: A cancel in either flow returns quietly. Other failures show copy from lib/errors/userFacingError.ts, never Clerk’s raw text. The native module ships only in a new store build; it cannot go out over the air.

Native Google sign-in configuration

The client IDs are public identifiers, not secrets. They come from the EAS environment (or a local .env), never from the repo. app.config.js copies them into extra, where Clerk’s hook and config plugin read them, and appends .apps.googleusercontent.com to a client ID given without it. Without them the app uses the browser flow and never touches the native module. The URL scheme gate matters because GoogleSignIn on iOS raises a native exception, which JavaScript cannot catch, when the reversed client ID scheme is missing from the app.
1

Google Cloud

  1. A Web application OAuth client. Its ID and secret are the custom credentials on Clerk’s Google connection.
  2. An iOS OAuth client for bundle ID com.soundchecklive.app (with the Apple Team ID).
  3. An Android OAuth client for package com.soundchecklive.app with the SHA-1 of the EAS upload keystore (eas credentials -p android). Builds installed from Google Play are re-signed, so add a second Android client with the SHA-1 of the Play app signing key (Play Console → App integrity). A new Android client can take a few hours to start working; until then the app falls back to the browser.
2

Clerk dashboard (each instance used by dev, qa and prod builds)

  1. SSO connections → Google: enabled, with custom credentials (the web client ID and secret from step 1).
  2. Native applications: register the iOS app (Team ID + bundle ID) and the Android app (package name + SHA-256 fingerprints of the upload and Play signing keys).
  3. Keep soundcheck://oauth-callback in the allowed redirect URLs so the browser fallback keeps working.
3

EAS environment variables

Set the variables in the table above (plain-text visibility), each matching the Clerk instance behind that environment’s publishable key. Then make a new native build.

Apple sign in

Apple Sign In is not offered on every platform: On iOS and web, post-auth redirects use /(tabs)/events, the Expo Router path for the tab labeled Gigs:

Configuration

iOS configuration

Apple Sign In requires iOS entitlements. These are configured in app.config.js:
The expo-apple-authentication plugin is included automatically.

Clerk dashboard setup

To enable social authentication:
1

Enable OAuth Providers

  1. Go to Clerk Dashboard
  2. Navigate to User & Authentication → Social Connections
  3. Enable Google and/or Apple
2

Configure Google OAuth

  1. Create OAuth credentials in Google Cloud Console
  2. Add credentials to Clerk Dashboard
  3. Configure redirect URLs
3

Configure Apple Sign In

  1. Enable Sign In with Apple in Apple Developer Console
  2. Create Services ID for OAuth
  3. Generate private key
  4. Add credentials to Clerk Dashboard
Apple Sign In requires an Apple Developer account ($99/year).

Token management

How tokens work

Token lifecycle

  1. Generation: Clerk creates a JWT when user signs in
  2. Caching: Token is stored in SecureStore via tokenCache
  3. Retrieval: getToken() returns the current valid token
  4. Refresh: Clerk automatically refreshes expired tokens
  5. Expiration: Tokens expire after 1 hour (configurable in Clerk)

Token format

All authenticated requests include:

AuthContext

The AuthContext provides authentication state throughout the app:

Provider setup

The AuthProvider must be inside ClerkProvider:

Error handling

Common OAuth errors

This is expected behavior when users cancel authentication:
The Services ID or configuration doesn’t match between Apple and Clerk:
  1. Verify Services ID in Clerk matches Apple Developer Console
  2. Check redirect URLs match exactly
  3. Ensure the Services ID is enabled for Sign In with Apple
Private key or Team ID mismatch:
  1. Re-enter the private key in Clerk Dashboard
  2. Verify Team ID is correct (10 characters)
  3. Verify Key ID is correct (10 characters)
OAuth redirect not working:
  1. Verify scheme: "soundcheck" in app.config.js
  2. Rebuild the app with eas build
  3. Check Clerk Dashboard OAuth redirect configuration

Security

Best practices

  1. Never commit secrets - Keep Clerk keys in environment variables
  2. Use SecureStore - Tokens are stored securely in iOS Keychain/Android Keystore
  3. Short-lived tokens - JWT tokens expire, limiting vulnerability window
  4. Automatic refresh - Clerk handles token refresh automatically
  5. Revocable sessions - Sessions can be revoked from Clerk Dashboard

Environment variables

Never include CLERK_SECRET_KEY in mobile app code. It’s only for server-side use.

Testing authentication

Debug checklist

  1. Check token is being sent:
    • Open React Native debugger
    • Check Network tab
    • Verify Authorization: Bearer ... header
  2. Verify user state:
  3. Test with cURL:

Resources