Expo Google Auth Module
The `expo-google-auth` package, currently at version 0.3.0, offers a dedicated solution for integrating Google authentication into React Native Expo applications. It achieves this by leveraging Google's modern Identity API and Credential Manager, presenting an updated approach to handling user sign-ins compared to traditional methods. While it provides two primary authentication methods, the module explicitly recommends "Method 1" as the latest approach endorsed by Google. A crucial aspect of this library is its current platform limitation: it exclusively supports Android environments. Developers targeting iOS are directed to use `expo-auth-session` for their authentication needs. Launched publicly in November 2025, the package has seen a consistent, albeit minor, release cadence, signaling ongoing development. To function correctly, users must perform essential Google Credentials setup for both Android and web clients, which includes obtaining and configuring a Google Web Client ID. This package aims to simplify Google sign-in workflows specifically for Android within the Expo ecosystem.
Common errors
-
Failed to authenticate. ID token is null or undefined.
cause Google credentials (e.g., Google Web Client ID, SHA-1 fingerprints for Android) are incorrectly configured or missing in the Google Cloud Console.fixVerify that your Google Web Client ID is correct, the Android client is registered with the correct package name and SHA-1 fingerprint in the Google Cloud Console, and ensure the API is enabled. -
TypeError: ExpoGoogleAuth.launchGoogleAuth is not a function
cause This error typically occurs when attempting to use CommonJS `require()` syntax with an ESM-only package, or when TypeScript/Babel transpilation is misconfigured.fixEnsure you are using `import ExpoGoogleAuth from 'expo-google-auth';` in your JavaScript/TypeScript files. If using CommonJS, consider project-wide migration to ESM or using dynamic import. -
Module not found: Can't resolve 'expo-google-auth'
cause The package `expo-google-auth` has not been installed, or there's a typo in the import path.fixRun `npm install expo-google-auth` or `yarn add expo-google-auth` in your project directory. Double-check the spelling of the import path.
Warnings
- gotcha This module currently provides native Google authentication support exclusively for Android. For iOS applications, developers are explicitly advised to use `expo-auth-session`.
- gotcha Successful Google authentication requires proper setup of Google Credentials, including obtaining a Google Web Client ID (GWC ID) and configuring it in the Google Cloud Console for your Android application (and potentially web client).
- gotcha The `launchGoogleAuth` method accepts two string arguments: 'GID' (recommended) or 'SWIG' (traditional). While both may work, Google's latest recommendations favor the 'GID' approach.
Install
-
npm install expo-google-auth -
yarn add expo-google-auth -
pnpm add expo-google-auth
Imports
- ExpoGoogleAuth
const ExpoGoogleAuth = require('expo-google-auth');import ExpoGoogleAuth from 'expo-google-auth';
Quickstart
import ExpoGoogleAuth from 'expo-google-auth';
import { Alert } from 'react-native'; // For showing results in a real app
const MY_GOOGLE_WEB_CLIENT_ID = process.env.GOOGLE_WEB_CLIENT_ID ?? 'YOUR_GWC_ID_HERE'; // Replace with your actual GWC ID
async function signInWithGoogle() {
if (MY_GOOGLE_WEB_CLIENT_ID === 'YOUR_GWC_ID_HERE') {
Alert.alert('Configuration Error', 'Please replace YOUR_GWC_ID_HERE with your actual Google Web Client ID.');
return;
}
try {
// Method 1: Latest, Recommended by Google
const idToken = await ExpoGoogleAuth.launchGoogleAuth("GID", MY_GOOGLE_WEB_CLIENT_ID);
if (idToken) {
Alert.alert('Sign-in Successful', `Received ID Token: ${idToken.substring(0, 30)}...`);
console.log('Google ID Token:', idToken);
// Now, provide this id token to your backend auth provider
} else {
Alert.alert('Sign-in Failed', 'No ID token received.');
}
} catch (error) {
console.error('Google Sign-in Error:', error);
Alert.alert('Sign-in Error', error.message || 'An unknown error occurred during Google sign-in.');
}
}
// Example of how to call it (e.g., from a button press in a React Native component)
signInWithGoogle();