React Native通过Google登录AWS时出现GooglesigninError(code:10)求助
Fixing Google Sign-In Error Code 10 in AWS Amplify React Native Projects
Hey there, sorry to hear you're stuck with Google Sign-In Error Code 10 while building your AWS-based feature—let’s break this down and get you back on track. Error Code 10 typically points to mismatched client IDs or incomplete fingerprint/SHA configurations, so let’s walk through targeted fixes:
1. Double-Check Google Cloud Console OAuth Client IDs
- You need two distinct client IDs for this setup:
- An Android client ID (for your React Native Android app)
- A Web application client ID (used by Amplify’s OAuth flow)
- Confirm the Android client ID’s SHA1 fingerprint matches exactly what you’re using locally—remember: debug and release builds have different SHA1s! If you’re testing in debug mode, make sure you’ve added the debug SHA1 to this client ID.
- Ensure the Web client ID is correctly copied into your Amplify config (more on that next).
2. Verify Amplify Auth Configuration
Open your aws-exports.js and cross-check the OAuth section against this example:
oauth: { domain: 'your-user-pool-domain.auth.region.amazoncognito.com', scope: ['email', 'openid', 'profile'], redirectSignIn: 'myapp://callback', // Match this to Google Console's authorized URIs redirectSignOut: 'myapp://signout', responseType: 'code', google: { webClientId: 'YOUR_GOOGLE_WEB_CLIENT_ID' // Use the Web client ID from Google Console } }
- Critical: The
redirectSignInandredirectSignOutvalues must exactly match the "Authorized redirect URIs" you’ve set in the Google Cloud Console (including scheme, case, and path).
3. Validate google-services.json Setup
- For Android, make sure
google-services.jsonlives inandroid/app/(not a subfolder). - Open the file and confirm:
client[0].oauth_client[0].client_idis your Android client ID- If a Web client ID is included, it matches the one you’re using in Amplify
- If Firebase didn’t include the Web client ID in the file, manually add it by copying from the Google Cloud Console.
4. Clear Caches and Rebuild (Don’t Skip This!)
Old cached configurations are a common culprit. Run these commands to do a clean rebuild:
# Reset React Native cache npx react-native start --reset-cache # Clean Android build files cd android && ./gradlew clean && cd .. # Reinstall dependencies (optional but safe) npm install # Rebuild the app npx react-native run-android
5. Check AWS Cognito Identity Provider Settings
Head to the AWS Console, navigate to your Cognito User Pool, and verify the Google identity provider setup:
- Ensure the Client ID is your Google Web client ID, and the Client Secret matches the Web client’s secret from Google Console.
- Confirm the Authorized Scopes include
email,openid, andprofile—these must align with what’s in youraws-exports.js.
Bonus: Debug vs Release Mode Checks
- If testing a release build, you must use the release SHA1 fingerprint in your Google Cloud Console client ID. Generate it with:
keytool -list -v -keystore your-release-keystore.jks -alias your-alias - For debug builds, use this command to get the correct SHA1:
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
内容的提问来源于stack exchange,提问作者Bram Smith
相关产品推荐
相关产品推荐

