npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@stonega/expo-google-signin

v0.1.12

Published

Google SignIn for Expo

Downloads

26

Readme

Clay Google Sign-in

A React Native module for Google Sign-in. This module works for both iOS and Android.

Installation

npm install @stonega/google-signin

or

yarn add @stonega/google-signin

This library comes with a config plugin that handles the native project configuration for you.

Configuration

Environment Variables

The config plugin requires the following environment variables to be set in your .env file:

EXPO_PUBLIC_REVERSED_CLIENT_ID=your_reversed_client_id_here
EXPO_PUBLIC_IOS_CLIENT_ID=your_ios_client_id_here
EXPO_PUBLIC_GOOGLE_WEB_CLIENT_ID=your_web_client_id_here

These values can be found in your GoogleService-Info.plist file:

  • REVERSED_CLIENT_ID: The reversed client ID from your GoogleService-Info.plist
  • IOS_CLIENT_ID: The iOS client ID from your GoogleService-Info.plist
  • GOOGLE_WEB_CLIENT_ID: The web client ID from your GoogleService-Info.plist

Google Services Configuration

Configure in app.config.js:

export default {
  // ... other config
  android: {
    googleServicesFile: process.env.GOOGLE_SERVICES_JSON ?? '/local/path/to/google-services.json',
  },
  ios: {
    googleServicesFile: process.env.GOOGLE_SERVICES_PLIST ?? '/local/path/to/GoogleService-Info.plist',
  },
};

iOS

  1. Follow the Google Sign-In for iOS integration guide to get your GoogleService-Info.plist file.
  2. Place this file in the root of your project (e.g., alongside App.js). The config plugin will automatically copy this file to the native project and configure the required URL Schemes and Client ID in your Info.plist.
  3. Run npx expo prebuild to sync the native project files.

Android

  1. Go to your project in the Firebase console.
  2. In your project settings, download the google-services.json file.
  3. Place this file in the root of your project (e.g., alongside App.js).
  4. The config plugin will automatically copy the file and configure Gradle during the prebuild process.
  5. Run expo prebuild to sync the changes.

Usage

First, you need to configure the module, usually in your app's entry file.

import { GoogleSignin } from 'clay-google-signin';

GoogleSignin.configure({
  webClientId: 'YOUR_WEB_CLIENT_ID', // client ID of type WEB for your server (needed to verify user ID and for offline access)
  iosClientId: 'YOUR_IOS_CLIENT_ID', // found in your GoogleService-Info.plist
});

Then, you can use the GoogleSigninButton component and the GoogleSignin API.

import { GoogleSignin, GoogleSigninButton, User } from 'clay-google-signin';
import React, { useState } from 'react';
import { View, Text, Button, Alert } from 'react-native';

function App() {
  const [user, setUser] = useState<User | null>(null);

  const signIn = async () => {
    try {
      await GoogleSignin.hasPlayServices();
      const userInfo = await GoogleSignin.signIn();
      setUser(userInfo);
    } catch (error: any) {
      if (error.code !== '-5') { // -5 is user cancellation
        Alert.alert("Sign In Error", error.message);
      }
    }
  };

  const signOut = async () => {
    try {
      await GoogleSignin.signOut();
      setUser(null);
    } catch (error: any) {
      Alert.alert('Sign Out Error', error.message);
    }
  };

  if (!user) {
    return (
      <View>
        <GoogleSigninButton onPress={signIn} />
      </View>
    );
  }

  return (
    <View>
      <Text>Welcome, {user.name}</Text>
      <Button title="Sign Out" onPress={signOut} />
    </View>
  )
}

API

The GoogleSignin object provides the following methods:

  • hasPlayServices(params?: { showPlayServicesUpdateDialog: boolean }): Promise<boolean> (Android only)
  • configure(params: ConfigureParams): Promise<void>
  • signIn(): Promise<User>
  • signInSilently(): Promise<User | null>
  • signOut(): Promise<void>
  • revokeAccess(): Promise<void>
  • hasPreviousSignIn(): Promise<boolean>
  • getCurrentUser(): Promise<User | null>
  • getTokens(): Promise<{ idToken: string; accessToken: string }>
  • addScopes(scopes: string[]): Promise<User>
  • clearCachedAccessToken(token: string): Promise<void>

See src/ClayGoogleSignin.types.ts for the shape of the User object and ConfigureParams.

Troubleshooting

Android Error 12502

This error indicates a mismatch between your app's signing certificate and the SHA-1 fingerprint registered in your Firebase project.

Step 1: Get the SHA-1 Fingerprint

  1. Navigate to the android directory of your project (e.g., cd android).
  2. Run the ./gradlew signingReport command.
  3. In the output, find the SHA-1 value for the debug variant and copy it.

Step 2: Add the Fingerprint to Firebase

  1. Open your project in the Firebase console.
  2. Go to Project settings > General tab.
  3. Scroll down to "Your apps" and select your Android app.
  4. Click "Add fingerprint" and paste the SHA-1 key you copied.
  5. Save your changes. It may take a few minutes for the new settings to apply.
  6. Rebuild your app.