Expo Google Auth Module

0.3.0 · active · verified Wed Apr 22

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

Warnings

Install

Imports

Quickstart

Demonstrates how to initiate Google authentication using the recommended 'GID' method and handle the returned ID token. Includes error handling and prompts for necessary configuration.

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();

view raw JSON →