For most modern apps, authentication options have become more flexible. Rather than relying on traditional email-password combinations, users now prefer faster, secure login options such as Google, Apple, GitHub, etc., commonly referred to as Single Sign-On (SSO).
We recently added Login with Google in our mobile app, and during the process, we faced a few challenges. In this guide, I’ll walk you through the steps to implement Google Sign-In in a React Native app, share how to handle the login response, validate the user, manage sessions—and cover some common errors like the dreaded developer_error.
Fixing developer_error
Before using Google Sign-In, create a project in the Google Developer Console:
Go to the Console and create a new project or select an existing one.
Navigate to APIs & Services > Credentials.
Click Create Credentials → Select OAuth Client ID.
Choose Web Application.
Additionally, create OAuth credentials for Android and iOS clients.
ℹ️ Tip: To find the SHA-1 key for Android, see point #10 below.
You will now have three client IDs:
Web
Android
iOS
If you haven’t already, create your React Native project:
npx react-native init MyGoogleSignInApp cd MyGoogleSignInApp
Install the official package:
npm install @react-native-google-signin/google-signin
For setup instructions, refer to the official documentation.
Add the following configuration to your main JS file (e.g., index.js) or to a dedicated service:
import { GoogleSigninButton, GoogleSignin } from '@react-native-google-signin/google-signin';GoogleSignin.configure({
webClientId: '732276031820-vnekqp4tecccxcxnlidkbct04d9hgr4b8d12j.apps.googleusercontent.com',
//for android, webclient is used for android too
scopes: ['profile', 'email'],
offlineAccess: true,
});✅ Store all client IDs in a
.envfile for security.
Here’s a simple button to trigger login (styling excluded for brevity):
import { GoogleSigninButton, GoogleSignin } from '@react-native-google-signin/google-signin';
const GoogleLogin = async () => {
try {
await GoogleSignin.hasPlayServices();
const userInfo = await GoogleSignin.signIn();
console.log("userInfo", userInfo);
return userInfo;
} catch (error) {
console.error("Google Sign-In Error:", error);
throw error;
}
};
const handleGoogleLogin = async () => {
try {
const response: any = await GoogleLogin();
const { data } = response;
console.log("google", data)
} catch (apiError) {
} finally {
}
};
<GoogleSigninButton
size={GoogleSigninButton.Size.Wide}
color={GoogleSigninButton.Color.Dark}
onPress={() => {
handleGoogleLogin()
}}
/>The login logic includes:
Checking if Play Services are available.
Triggering the sign-in flow.
Receiving user info and token.
Sending the token to your backend for validation.
The backend should verify the token using Google’s API:
jsCopyEdit
await axios.get( https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=${token} );
Once validated, create or authenticate the user on your server.
🔐 Make sure this call is made server-side, not from the client.
To maintain sessions:
Use JWTs or secure session cookies.
Attach session info to the user profile or store it in secure storage on the device (e.g., @react-native-async-storage/async-storage).
developer_errorYou may encounter a developer_error while integrating Google Sign-In. Here’s how to fix it:
SHA-1 mismatch
Ensure the SHA-1 used in the Google Developer Console matches the one from your keystore. Get it using:
bashcd android
keytool -list -v -keystore app/debug.keystore
Default password:
android
Incorrect package/bundle name
Ensure that the app’s bundle ID matches what you used when generating the client IDs.
Implementing Google Sign-In in React Native can be smooth once you’ve correctly configured all credentials and understand the token validation process. While the developer_error is a common hurdle, it's easily fixable with the right setup.
This guide should help you get started and avoid common pitfalls. If you're integrating SSO options into your app, Google is a great starting point.