Mobile Auth Setup (Backend Side)
The MysticX mobile app (Expo) authenticates against this Next.js backend using Better Auth's Expo integration.
What's done
@better-auth/exposerver plugin installed and added tolib/auth.tsxtrustedOriginsupdated withmysticx://scheme and devexp://patterns- Google OAuth already works (same client ID)
- Email/password login already works
- Optional env vars added to
env.tsfor Apple and Facebook (see below)
What's TODO
Apple Sign In
- Get credentials from Apple Developer Portal (see
mysticx-app/docs/mobile-auth-setup.md) - Add to
.env:APPLE_CLIENT_ID=com.mysticx.app.si APPLE_TEAM_ID=XXXXXXXXXX APPLE_KEY_ID=YYYYYYYYYY APPLE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----" - Install
jose:pnpm add jose - Uncomment Apple provider in
lib/auth.tsxand implementgenerateAppleClientSecret() - Uncomment
'https://appleid.apple.com'intrustedOrigins
Facebook Login
- Get credentials from Facebook Developer Portal (see
mysticx-app/docs/mobile-auth-setup.md) - Add to
.env:FACEBOOK_CLIENT_ID=your_app_id FACEBOOK_CLIENT_SECRET=your_app_secret - Uncomment Facebook provider in
lib/auth.tsx
Google (mobile-specific)
- The existing
GOOGLE_CLIENT_IDworks for idToken verification from the mobile app - Mobile app uses
@react-native-google-signin/google-signinfor native sign-in flow - The native SDK gets an idToken, which is sent to our backend via
signIn.social({ provider: 'google', idToken: { token } }) - Backend verifies the token with Google and creates a session