Projects included: - maerchenzauber (NestJS backend + Expo mobile + SvelteKit web + Astro landing) - manacore (Expo mobile + SvelteKit web + Astro landing) - manadeck (NestJS backend + Expo mobile + SvelteKit web) - memoro (Expo mobile + SvelteKit web + Astro landing) This commit preserves the current state before monorepo restructuring. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
14 KiB
Social Authentication Setup Guide for Manadeck
This guide explains how to set up Google Sign-In and Apple Sign-In for the Manadeck mobile app.
Overview
Manadeck uses Mana Core authentication middleware which supports:
- Email/Password authentication
- Google Sign-In (Android & iOS)
- Apple Sign-In (iOS only)
All authentication methods issue JWT tokens that work with your Supabase backend and respect Row-Level Security (RLS) policies.
Prerequisites
Required Accounts and Credentials
-
Google Cloud Console Account
- OAuth 2.0 credentials for Android and iOS
- Web Client ID (for Android)
- iOS Client ID (for iOS)
-
Apple Developer Account
- Sign in with Apple capability enabled
- App ID configured with Sign in with Apple
-
Mana Core Backend
- Backend must support
/v1/auth/google-signinand/v1/auth/apple-signinendpoints - Backend URL configured in
.env.local
- Backend must support
Installation
The required dependencies are already installed:
@react-native-google-signin/google-signin@^14.0.1expo-apple-authentication@~8.0.7base64-js
Configuration Steps
1. Google Cloud Console Setup
Create OAuth Credentials
- Go to Google Cloud Console
- Create a new project or select existing project
- Navigate to APIs & Services → Credentials
For Android:
- Click Create Credentials → OAuth 2.0 Client ID
- Select Android as application type
- Fill in:
- Package name:
com.tilljs.manadeck - SHA-1 certificate fingerprint: Get from
cd android && ./gradlew signingReport
- Package name:
- Click Create
For iOS:
- Click Create Credentials → OAuth 2.0 Client ID
- Select iOS as application type
- Fill in:
- Bundle ID:
com.tilljs.manadeck
- Bundle ID:
- Click Create
- Save the iOS Client ID (format:
XXXXX.apps.googleusercontent.com)
For Web (Required for Android):
- Click Create Credentials → OAuth 2.0 Client ID
- Select Web application as application type
- Fill in:
- Name: Manadeck Web (for Android)
- Click Create
- Save the Web Client ID (format:
XXXXX.apps.googleusercontent.com)
2. Apple Developer Console Setup
Enable Sign in with Apple
- Go to Apple Developer Portal
- Navigate to Certificates, Identifiers & Profiles
- Click Identifiers in the sidebar
- Find and select your App ID:
com.tilljs.manadeck - In the Capabilities section, find Sign in with Apple
- Check the Sign in with Apple checkbox
- Click Save
Configure in Xcode (Optional but Recommended)
- Open your iOS project:
cd /Users/tillschneider/Documents/__00__Code/manadeck/apps/mobile open ios/manadeck.xcworkspace - Select your project target in the left sidebar
- Go to Signing & Capabilities tab
- Click + Capability button
- Add Sign in with Apple
- Ensure proper signing team is selected (Team ID: QP3GLU8PH3)
3. Update Environment Variables
Edit /Users/tillschneider/Documents/__00__Code/manadeck/apps/mobile/.env.local:
# Existing Supabase Configuration
EXPO_PUBLIC_SUPABASE_URL=https://vksoodohrbjwyloitvsz.supabase.co
EXPO_PUBLIC_SUPABASE_ANON_KEY=sb_publishable_2ndX-kBHFpbDlL_ZeeOnfQ_ZlLI8ONk
# Existing Backend API Configuration
EXPO_PUBLIC_API_URL=https://manadeck-backend-pduya7fsoq-ey.a.run.app
# Google OAuth Configuration (ADD THESE)
# Web Client ID (used for Android authentication)
EXPO_PUBLIC_GOOGLE_CLIENT_ID=YOUR_WEB_CLIENT_ID.apps.googleusercontent.com
# iOS Client ID (used for iOS authentication)
EXPO_PUBLIC_GOOGLE_IOS_CLIENT_ID=YOUR_IOS_CLIENT_ID.apps.googleusercontent.com
Replace the placeholder values with your actual OAuth Client IDs from Google Cloud Console.
4. Update app.json
The app.json has already been configured with:
{
"expo": {
"ios": {
"config": {
"googleSignIn": {
"reservedClientId": "com.googleusercontent.apps.PLACEHOLDER_IOS_CLIENT_ID"
}
},
"usesAppleSignIn": true
},
"plugins": [
"expo-router",
"@react-native-google-signin/google-signin",
"expo-apple-authentication"
]
}
}
Important: Replace PLACEHOLDER_IOS_CLIENT_ID in app.json with your actual iOS Client ID (without the com.googleusercontent.apps. prefix).
For example, if your iOS Client ID is 123456789-abc123.apps.googleusercontent.com, the reservedClientId should be:
"reservedClientId": "com.googleusercontent.apps.123456789-abc123"
5. Rebuild Native Code
After updating app.json and environment variables, rebuild the native code:
cd /Users/tillschneider/Documents/__00__Code/manadeck/apps/mobile
# For iOS
npx expo prebuild --clean
npx expo run:ios
# For Android
npx expo prebuild --clean
npx expo run:android
6. IMPORTANT: Manually Add iOS URL Scheme
⚠️ Critical Step: The Expo plugin may not automatically add the Google Sign-In URL scheme to iOS. You must verify and add it manually.
Verify and Add URL Scheme to Info.plist
- Open
ios/manadeck/Info.plist - Find the
CFBundleURLTypesarray - Add a new URL scheme entry for Google Sign-In:
<key>CFBundleURLTypes</key>
<array>
<!-- Existing URL schemes -->
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>manadeck</string>
<string>com.tilljs.manadeck</string>
</array>
</dict>
<!-- Add this new entry for Google Sign-In -->
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>com.googleusercontent.apps.111768794939-cgen6eklloo7k8vppcaq01o8r8nd7anb</string>
</array>
</dict>
</array>
Replace 111768794939-cgen6eklloo7k8vppcaq01o8r8nd7anb with your actual iOS Client ID.
Why This is Required
Without this URL scheme, Google Sign-In will fail with:
Your app is missing support for the following URL schemes:
com.googleusercontent.apps.XXXXX
iOS uses this URL scheme to redirect back to your app after Google authentication.
Backend Requirements
Your Mana Core backend must support the following endpoints:
POST /v1/auth/google-signin
⚠️ Important: The backend expects deviceInfo as a nested object, not spread at the root level.
Request body:
{
"token": "GOOGLE_ID_TOKEN",
"deviceInfo": {
"deviceId": "device-uuid",
"deviceName": "iPhone 15 Pro",
"deviceType": "ios"
}
}
Response:
{
"appToken": "JWT_TOKEN",
"refreshToken": "REFRESH_TOKEN"
}
POST /v1/auth/apple-signin
⚠️ Important: The backend expects deviceInfo as a nested object, not spread at the root level.
Request body:
{
"token": "APPLE_IDENTITY_TOKEN",
"deviceInfo": {
"deviceId": "device-uuid",
"deviceName": "iPhone 15 Pro",
"deviceType": "ios"
}
}
Response:
{
"appToken": "JWT_TOKEN",
"refreshToken": "REFRESH_TOKEN"
}
Common Error: If you send device info spread at root level instead of nested:
// ❌ WRONG - Will fail with "Complete device information is required"
{
"token": "...",
"deviceId": "...",
"deviceName": "...",
"deviceType": "ios"
}
// ✅ CORRECT - deviceInfo as nested object
{
"token": "...",
"deviceInfo": {
"deviceId": "...",
"deviceName": "...",
"deviceType": "ios"
}
}
Testing
Test on iOS
-
Build and run:
cd /Users/tillschneider/Documents/__00__Code/manadeck/apps/mobile npx expo run:ios -
Test Google Sign-In:
- Tap "Mit Google anmelden"
- Should show Google account picker
- Select account
- Should authenticate and navigate to home
-
Test Apple Sign-In:
- Tap "Mit Apple anmelden"
- Should show Face ID/Touch ID prompt
- Authenticate
- Should navigate to home
Test on Android
-
Build and run:
npx expo run:android -
Test Google Sign-In:
- Tap "Mit Google anmelden"
- Should show Google account picker
- Select account
- Should authenticate and navigate to home
-
Apple Sign-In won't show on Android (iOS only)
Project Structure
The social authentication implementation includes:
manadeck/apps/mobile/
├── services/
│ └── authService.ts # Extended with Google/Apple methods
├── store/
│ └── authStore.ts # Updated with social sign-in actions
├── components/
│ └── auth/
│ ├── GoogleSignInButton.tsx # Google Sign-In button component
│ └── AppleSignInButton.tsx # Apple Sign-In button component
├── app/
│ └── (auth)/
│ └── login.tsx # Updated with social buttons
├── app.json # Configured with plugins
└── .env.local # OAuth credentials
Troubleshooting
Google Sign-In Issues
"Your app is missing support for the following URL schemes" on iOS
Cause: Google Sign-In URL scheme not added to Info.plist
Solution:
- Open
ios/manadeck/Info.plist - Add the Google Sign-In URL scheme to
CFBundleURLTypes:<dict> <key>CFBundleURLSchemes</key> <array> <string>com.googleusercontent.apps.YOUR_IOS_CLIENT_ID</string> </array> </dict> - Replace
YOUR_IOS_CLIENT_IDwith your actual iOS Client ID - Rebuild the app:
npx expo run:ios
"DEVELOPER_ERROR" on Android
Cause: SHA-1 fingerprint mismatch or incorrect web client ID
Solution:
# Get your SHA-1
cd android && ./gradlew signingReport
# Add SHA-1 to Google Cloud Console
# Use Web Client ID (not Android Client ID) in EXPO_PUBLIC_GOOGLE_CLIENT_ID
"Sign-in failed" on iOS
Cause: Incorrect iOS Client ID or bundle identifier mismatch
Solution:
- Verify
EXPO_PUBLIC_GOOGLE_IOS_CLIENT_IDmatches Google Cloud Console - Verify bundle identifier in
app.jsonmatches Google Cloud Console - Update
reservedClientIdinapp.jsonwith correct iOS Client ID
"Play Services not available"
Cause: Google Play Services missing or outdated on Android
Solution:
- Update Google Play Services on device
- Test on device with Google Play Store installed
- Use emulator with Google Play
Apple Sign-In Issues
Button doesn't appear
Cause: Platform is not iOS
Solution: Apple Sign-In only works on iOS 13+
"Operation canceled" every time
Cause: Sign in with Apple not enabled in developer portal
Solution:
- Enable capability in Apple Developer Portal
- Add capability in Xcode
- Ensure
usesAppleSignIn: trueinapp.json
Backend Connection Issues
"Complete device information is required"
Cause: Device info sent incorrectly (spread at root instead of nested object)
Solution:
Ensure your authService sends deviceInfo as a nested object:
// ✅ Correct
body: JSON.stringify({
token: idToken,
deviceInfo, // Nested object
})
// ❌ Wrong
body: JSON.stringify({
token: idToken,
...deviceInfo, // Spread at root - will fail
})
"Network error" or timeout
Cause: Backend URL incorrect or unreachable
Solution:
- Verify
EXPO_PUBLIC_API_URLis correct - Test backend health endpoint
- Check network connectivity
- Ensure HTTPS is used (not HTTP)
"Invalid token" or "Authentication failed"
Cause: Backend endpoints not implemented or configured incorrectly
Solution:
- Verify backend supports
/v1/auth/google-signinand/v1/auth/apple-signin - Check backend logs for detailed error messages
- Ensure backend validates tokens correctly with Google/Apple
Security Considerations
- Never commit credentials: Keep
.env.localin.gitignore - Use HTTPS only: Always use HTTPS for backend communication
- Validate tokens on backend: Always validate social tokens on the backend
- Device binding: Tokens are bound to device IDs for security
- Secure storage: Tokens stored using platform-specific secure storage
Production Setup
For Production Release
Android Production SHA-1:
When ready to publish to Google Play, get your production SHA-1:
# For EAS builds
eas credentials -p android
# Or if using your own keystore
keytool -list -v -keystore /path/to/release.keystore -alias YOUR_KEY_ALIAS
Add the production SHA-1 to your Android OAuth client in Google Cloud Console.
iOS Production:
The same iOS Client ID works for both development and production.
Additional Resources
- React Native Google Sign-In Documentation
- Expo Apple Authentication Documentation
- Google OAuth 2.0 Documentation
- Apple Sign In Guidelines
Quick Reference
Your Credentials (Fill in as you obtain them)
Web OAuth Client ID: ________________________________.apps.googleusercontent.com
iOS OAuth Client ID: ________________________________.apps.googleusercontent.com
Android SHA-1 (Debug): ________________________________
Android SHA-1 (Prod): ________________________________
Apple Team ID: QP3GLU8PH3
Bundle ID: com.tilljs.manadeck
Package Name: com.tilljs.manadeck
Important Commands
# Get Android SHA-1
cd android && ./gradlew signingReport
# Rebuild native code
npx expo prebuild --clean
# Run on iOS
npx expo run:ios
# Run on Android
npx expo run:android
# Build with EAS
eas build --profile development
Support
For issues or questions:
- Check the troubleshooting section above
- Review backend logs for detailed error messages
- Consult Google Cloud Console and Apple Developer Portal documentation
- Check that all credentials are correctly configured
Integration completed successfully! Social authentication is now available in the Manadeck mobile app.