单Firebase账号搭建双应用:管理员应用登录错误10求助
Hey there, let's tackle that Google sign-in error 10 you're hitting with your admin Ionic app. Error 10 in Firebase Auth almost always ties back to misconfigured OAuth credentials or app-specific setup gaps—let's break this down step by step to get you sorted.
1. Verify Firebase/Google Cloud OAuth Credentials (The Most Common Fix)
First off, don't assume your regular user app's config works for the admin app—they need separate credentials if they have unique package IDs/bundle IDs:
- Head to your Firebase project's Authentication > Sign-in method and double-check Google sign-in is enabled (it probably is since your user app works, but quick confirmation never hurts).
- Go to Project Settings > General > Your apps—if you haven't already added your admin Ionic app as a separate entry here, do it now. Each app (user vs admin) needs its own Firebase app registration.
- Copy the admin app's Web SDK config (you'll need this for your Ionic code later). Then jump over to the linked Google Cloud Console (same project), navigate to APIs & Services > Credentials:
- For Android: Make sure the debug/release SHA-1 fingerprints for your admin app are added to the OAuth 2.0 client ID. You can grab the debug fingerprint with this command:
Don't forget—emulator and device fingerprints might differ, so add both if you test on both.keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android - For iOS: Confirm the bundle ID in the OAuth client matches exactly what's in your Xcode project (no typos, case sensitivity matters!).
- For Web/PWA: Check that Authorized JavaScript origins and Authorized redirect URIs include your admin app's running address (like
http://localhost:8100for local testing).
- For Android: Make sure the debug/release SHA-1 fingerprints for your admin app are added to the OAuth 2.0 client ID. You can grab the debug fingerprint with this command:
2. Double-Check Ionic Project Firebase Config
Make sure your admin app is using its own Firebase config, not the regular user app's:
- Create or update a
firebase-config.tsfile in your Ionic project with the admin app's credentials from Firebase:export const firebaseConfig = { apiKey: "YOUR_ADMIN_APP_API_KEY", authDomain: "your-project.firebaseapp.com", projectId: "your-project-id", storageBucket: "your-project.appspot.com", messagingSenderId: "your-sender-id", appId: "YOUR_ADMIN_APP_ID", measurementId: "G-YOUR_MEASUREMENT_ID" }; - If you're using
@angular/fireor@ionic/firebase-auth, explicitly set the admin client ID in your Google sign-in provider setup:import { GoogleAuthProvider } from "@angular/fire/auth"; const googleProvider = new GoogleAuthProvider(); // Force use of the admin app's client ID to avoid mismatches googleProvider.setCustomParameters({ client_id: "YOUR_ADMIN_APP_CLIENT_ID" });
3. Clear Caches & Rebuild (Don't Skip This!)
Old cached configs are sneaky and often prevent new settings from taking effect:
- Clear Ionic's local cache:
ionic cache clear - Rebuild your project:
ionic build - For Android: Navigate to the
androidfolder and run:./gradlew clean - For iOS: Delete Xcode's Derived Data, then run
pod installin theiosfolder to refresh dependencies.
4. Check Platform-Specific SDKs
- Android: Ensure your emulator has the latest Google Play Services installed—outdated versions can break auth flows. You can update this via the emulator's extended controls.
- iOS: Confirm you've added the
GoogleSignInframework correctly, and that yourInfo.plistincludes the Google callback URL scheme:<key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLSchemes</key> <array> <string>com.googleusercontent.apps.YOUR_ADMIN_CLIENT_ID</string> </array> </dict> </array>
Error 10 is almost never a "mystery" issue—it's almost always a credential mismatch or missing setup step. Start with the OAuth credentials check, since that's the #1 culprit, and work your way down. You'll have that admin app logged in in no time!
内容的提问来源于stack exchange,提问作者Ciprian

