@ademhatay/expo-google-signin
v0.2.22
Published
Google Credential Manager native modules for React Native Expo
Maintainers
Readme
About The Project
@ademhatay/expo-google-signin provides a single JS API (signIn, signOut) and native implementations for both platforms:
- Android: modern Credential Manager flow (
One Tapand explicitGoogle button flow) - iOS: official
GoogleSignInnative SDK
This lets you keep one auth integration across platforms while still using platform-native UX.
Built With
- Expo Modules
- React Native
- AndroidX Credential Manager
- Google Identity Services for Android
- GoogleSignIn iOS SDK
Getting Started
Prerequisites
- Node.js LTS (
20or22recommended) - Expo SDK / React Native project
- Google Cloud project
Installation
Expo managed or prebuild:
npx expo install @ademhatay/expo-google-signinBare React Native / Expo bare:
npm install @ademhatay/expo-google-signin
# or
bun add @ademhatay/expo-google-signinRebuild native apps after install:
npx expo run:android
npx expo run:iosGoogle Cloud Setup (Required)
You must create OAuth clients in the same Google Cloud project.
1) Create Web OAuth Client (Required for all platforms)
Create OAuth client ID with type Web application.
Use this value as:
serverClientIdinsignIn(options)
Important: serverClientId must be Web Client ID, not Android/iOS client ID.
2) Create Android OAuth Client
Create OAuth client ID with type Android and enter:
- Package name (exactly your Android app package)
- SHA-1 certificate fingerprint(s)
Get SHA-1:
cd android
./gradlew signingReportAdd all relevant SHA-1 values (debug/release/play signing if applicable).
3) Create iOS OAuth Client
Create OAuth client ID with type iOS and enter:
- Bundle identifier (must match your iOS app bundle ID)
4) Configure OAuth Consent Screen
If app is in Testing, add test user emails.
5) Configure Expo plugin for iOS
In your app config (app.json or app.config.ts), add plugin with iOS client ID:
{
"expo": {
"plugins": [
[
"@ademhatay/expo-google-signin",
{
"iosClientId": "YOUR_IOS_CLIENT_ID.apps.googleusercontent.com"
}
]
]
}
}This writes GIDClientID and required URL scheme into Info.plist during prebuild.
Then rebuild iOS native project.
Usage
import { signIn, signOut } from '@ademhatay/expo-google-signin';
const user = await signIn({
serverClientId: 'YOUR_WEB_CLIENT_ID.apps.googleusercontent.com',
// Optional on iOS if plugin already set GIDClientID
iosClientId: 'YOUR_IOS_CLIENT_ID.apps.googleusercontent.com',
// Android options (ignored on iOS):
signInButtonFlow: false,
filterByAuthorizedAccounts: false,
preferImmediatelyAvailableCredentials: false,
});
console.log(user.idToken);
await signOut();Example env variables
EXPO_PUBLIC_GOOGLE_WEB_CLIENT_ID=YOUR_WEB_CLIENT_ID.apps.googleusercontent.com
EXPO_PUBLIC_GOOGLE_IOS_CLIENT_ID=YOUR_IOS_CLIENT_ID.apps.googleusercontent.comAPI Reference
signIn(options: GoogleSignInOptions): Promise<GoogleUser>
GoogleSignInOptions
serverClientId: string(required)- Web OAuth client ID from Google Cloud.
iosClientId?: string- iOS OAuth client ID. Optional if plugin sets
GIDClientIDin Info.plist.
- iOS OAuth client ID. Optional if plugin sets
nonce?: string- Optional nonce.
filterByAuthorizedAccounts?: boolean(Android)preferImmediatelyAvailableCredentials?: boolean(Android)signInButtonFlow?: boolean(Android)
Returns GoogleUser
id: stringidToken: stringdisplayName?: stringgivenName?: stringfamilyName?: stringprofilePictureUrl?: stringphoneNumber?: string
signOut(): Promise<void>
- Android: clears credential manager state.
- iOS: signs out current Google user.
Troubleshooting
serverClientId is required
- Ensure Web client ID is passed.
- Ensure env is loaded correctly.
Developer console is not set up correctly / DEVELOPER_ERROR
- Android package name mismatch.
- SHA-1 missing or wrong.
- Wrong client ID type used in
serverClientId.
iosClientId is required for iOS
- Add iOS client ID via plugin config or pass
iosClientIdinsignInoptions.
iOS build fails with Expo config/plugin errors
- Use Node LTS (
20or22), avoid Node25. - Reinstall pods and rebuild:
cd ios
pod installiOS build succeeds but sign-in fails
- Verify bundle identifier exactly matches iOS OAuth client.
- Verify OAuth consent screen test users.
Contributing
PRs and issues are welcome.
- Fork the project
- Create branch
- Commit changes
- Push branch
- Open PR
License
MIT © Adem Hatay
