Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,487 changes: 596 additions & 891 deletions README.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app.plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./plugin/build/withGoogleAuth');
23 changes: 19 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-google-auth",
"version": "1.0.0",
"version": "1.1.0-alpha.16",
"description": "🚀 Modern React Native Google Authentication library with TypeScript support. Features latest Google Sign-In SDK, OAuth 2.0, One Tap Sign-In, token management, and cross-platform iOS/Android integration. Perfect for implementing Google Login, Google SSO, and Google OAuth in React Native apps.",
"main": "./lib/module/index.js",
"types": "./lib/typescript/src/index.d.ts",
Expand All @@ -10,6 +10,7 @@
"types": "./lib/typescript/src/index.d.ts",
"default": "./lib/module/index.js"
},
"./app.plugin.js": "./app.plugin.js",
"./package.json": "./package.json"
},
"files": [
Expand All @@ -18,6 +19,8 @@
"android",
"ios",
"cpp",
"app.plugin.js",
"plugin/build",
"*.podspec",
"react-native.config.js",
"!ios/build",
Expand All @@ -37,7 +40,9 @@
"typecheck": "tsc",
"lint": "eslint \"**/*.{js,ts,tsx}\"",
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
"prepare": "bob build",
"prepare": "bob build && yarn build:plugin",
"build:plugin": "tsc --build plugin",
"clean:plugin": "expo-module clean plugin",
"release": "release-it --only-version"
},
"keywords": [
Expand Down Expand Up @@ -96,7 +101,10 @@
"del-cli": "^5.1.0",
"eslint": "^9.22.0",
"eslint-config-prettier": "^10.1.1",
"eslint-plugin-jest": "^29.0.1",
"eslint-plugin-prettier": "^5.2.3",
"expo": "^51.0.39",
"expo-module-scripts": "^3.5.4",
"jest": "^29.7.0",
"prettier": "^3.0.3",
"react": "19.1.0",
Expand All @@ -107,11 +115,18 @@
"typescript": "^5.8.3"
},
"peerDependencies": {
"expo": ">=52.0.40",
"react": "*",
"react-native": "*"
},
"peerDependenciesMeta": {
"expo": {
"optional": true
}
},
"workspaces": [
"example"
"example",
"plugin"
],
"packageManager": "yarn@3.6.1",
"jest": {
Expand Down Expand Up @@ -183,4 +198,4 @@
"type": "turbo-module",
"version": "0.53.0"
}
}
}
2 changes: 2 additions & 0 deletions plugin/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// @generated by expo-module-scripts
module.exports = require('expo-module-scripts/eslintrc.base.js');
228 changes: 228 additions & 0 deletions plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
# React Native Google Auth - Expo Plugin

An Expo config plugin for seamless Google Sign-In integration in React Native projects. This plugin automatically configures both iOS and Android platforms with minimal setup required.

## Features

- 🍎 **iOS Configuration**: Automatic Info.plist setup, URL schemes, and GoogleService-Info.plist integration
- 🤖 **Android Configuration**: AndroidManifest.xml setup, permissions, and google-services.json integration
- 🔧 **Smart Detection**: Automatically extracts client IDs from Google service files
- 📁 **File Management**: Copies Google service files to correct platform directories
- 🔄 **Firebase Compatible**: Falls back to standard Firebase configuration when needed
- ✅ **Validation**: Ensures proper client ID formats and configuration

## Installation

```bash
npm install react-native-google-auth
# or
yarn add react-native-google-auth
```

## Configuration

### Basic Setup (Recommended)

The easiest way to use this plugin is to place your Google service files in your project root and let the plugin handle everything automatically:

1. **Add Google service files to your project root:**
- `GoogleService-Info.plist` (for iOS)
- `google-services.json` (for Android)

2. **Add the plugin to your `app.config.js`:**

```javascript
export default {
expo: {
name: "Your App",
plugins: [
"react-native-google-auth"
]
}
};
```

### Advanced Configuration

For more control over the configuration, you can provide custom options:

```javascript
export default {
expo: {
name: "Your App",
plugins: [
[
"react-native-google-auth",
{
iosClientId: "your-ios-client-id.apps.googleusercontent.com",
androidClientId: "your-android-client-id.apps.googleusercontent.com",
googleServicesFile: "./path/to/google-services.json",
iosGoogleServicesFile: "./path/to/GoogleService-Info.plist"
}
]
]
}
};
```

## Configuration Options

| Option | Type | Required | Description |
|--------|------|----------|-------------|
| `iosClientId` | `string` | No | iOS OAuth client ID. Auto-extracted from GoogleService-Info.plist if not provided |
| `androidClientId` | `string` | No | Android OAuth client ID. Auto-extracted from google-services.json if not provided |
| `iosUrlScheme` | `string` | No | iOS URL scheme. Auto-extracted from iosClientId (first part before dot) if not provided |
| `googleServicesFile` | `string` | No | Custom path to google-services.json (default: `./google-services.json`) |
| `iosGoogleServicesFile` | `string` | No | Custom path to GoogleService-Info.plist (default: `./GoogleService-Info.plist`) |

## How It Works

### iOS Configuration

The plugin automatically:

1. **Copies GoogleService-Info.plist** to `ios/GoogleService-Info.plist`
2. **Extracts CLIENT_ID** from the plist file (if not manually provided)
3. **Adds GIDClientID** to Info.plist
4. **Configures URL scheme** based on the client ID (first part before the first dot)
5. **Validates client ID format** (must end with `.apps.googleusercontent.com`)

### Android Configuration

The plugin automatically:

1. **Copies google-services.json** to `android/app/google-services.json`
2. **Extracts client ID** from the JSON file (if not manually provided)
3. **Adds INTERNET permission** to AndroidManifest.xml (if not already present)
4. **Provides helpful logging** for debugging configuration issues

## Usage Examples

### Example 1: Automatic Configuration

```javascript
// app.config.js
export default {
expo: {
name: "MyApp",
plugins: ["react-native-google-auth"]
}
};
```

**Requirements:**
- `GoogleService-Info.plist` in project root
- `google-services.json` in project root

### Example 2: Custom File Paths

```javascript
// app.config.js
export default {
expo: {
name: "MyApp",
plugins: [
[
"react-native-google-auth",
{
googleServicesFile: "./config/google-services.json",
iosGoogleServicesFile: "./config/GoogleService-Info.plist"
}
]
]
}
};
```

### Example 3: Manual Client IDs

```javascript
// app.config.js
export default {
expo: {
name: "MyApp",
plugins: [
[
"react-native-google-auth",
{
iosClientId: "123456789-abcdef.apps.googleusercontent.com",
androidClientId: "123456789-ghijkl.apps.googleusercontent.com"
}
]
]
}
};
```

### Example 4: Custom URL Scheme

```javascript
// app.config.js
export default {
expo: {
name: "MyApp",
plugins: [
[
"react-native-google-auth",
{
iosClientId: "123456789-abcdef.apps.googleusercontent.com",
iosUrlScheme: "com.mycompany.myapp" // Custom URL scheme instead of auto-extracted
}
]
]
}
};
```

### Common Issues

1. **"No iOS client ID found" warning**
- Ensure `GoogleService-Info.plist` exists in your project root
- Or provide `iosClientId` manually in the plugin configuration

2. **"No Android client ID found" warning**
- Ensure `google-services.json` exists in your project root
- Or provide `androidClientId` manually in the plugin configuration

3. **"Source file not found" error**
- Check that your Google service files are in the correct location
- Verify the file paths in your plugin configuration

4. **iOS client ID format error**
- Ensure your iOS client ID ends with `.apps.googleusercontent.com`
- Double-check the CLIENT_ID value in your GoogleService-Info.plist

### Debug Logging

The plugin provides comprehensive logging during the configuration process:

- ✅ Success messages for file operations
- ⚠️ Warnings for missing files or configuration
- 🍎 iOS-specific configuration steps
- 🤖 Android-specific configuration steps
- 🚀 Overall plugin status

## Firebase Compatibility

When no options are provided, the plugin falls back to standard Expo Firebase configuration:

- Uses `AndroidConfig.GoogleServices` for Android
- Uses `IOSConfig.Google` for iOS
- Automatically applies Google Services plugins and files

## Requirements

- Expo SDK 47+
- React Native Google Auth library
- Valid Google OAuth credentials

## Support

For issues and questions:
1. Check the troubleshooting section above
2. Verify your Google service files are correctly formatted
3. Ensure your OAuth client IDs are properly configured in Google Cloud Console

## License

This plugin is part of the react-native-google-auth package.
Loading
Loading