This project comes set up with react-native-google-signin out of the box, allowing you to take full advantage of Google's native SDK. Example authentication code can be found in src/providers/Google.tsx.
As with all third party authentication providers you will need to configure your project details to use Google's SDK.
Please note, Google authentication is currently only available on native platforms.
This guide assumes that you have already created your Firebase app and configured your iOS and Android projects as explained in README.
To begin, replace the webClientId in src/config.json
with your own, which is used by the app to call GoogleSignin.configure
; and is needed whenever that method is called. This ID is automatically generated when you create your Firebase project and you can find it under "Web Application -> Client ID" in your Google Cloud Console. Make sure you select right project.
-
Open your project via XCode and navigate to your
GoogleService-Info.plist
file (normally located at/ios/[YourApp]/Info.plist
). Copy yourREVERSED_CLIENT_ID
from this file. -
Alternatively, click on your xcode project icon (blue one) and under Info tab expand
URL Types
panel. Add new url type and underURL Schema
paste your previously coppiedREVERSED_CLIENT_ID
field value. NOTE: you might see more entries here if you use other social auth providers like Facebook. -
Run your app and make sure that everything is working. If you run into any trouble it is worth trying to clean your caches and restart XCode (possibly via
npx react-native-clean-project
)
Android uses keystore
system for app signing, if you haven't already done so you will need to generate keystore files for debug (later also release) builds.
In depth information about this is available in Android keystore documentation
-
If you don't have one generate a
debug.keystore
file in yourandroid/app
directory. These keystore files are required to run android apps in debug and release mode. To generate debug keystore file run following command withinandroid/app
folder (use all default presets when prompted by terminal).keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000
-
After you generated your
debug.keystore
file, run following command in the same folder (android/app
) to obtain your SHA1 and SHA256 certificate fingerprints. Copy both of them, you will need them in the next step.keytool -list -v -keystore ./debug.keystore -alias androiddebugkey -storepass android -keypass android
-
Once you have your SHA1 and SHA256 certificate fingerprints go yo your Firebase project settings, choose your android app and certificate fingerprints you copied from the previous step.
-
Re-download your
google-services.json
file and move it toandroid/app
folder (replace your old file if needed). -
Now clean your android project: In android studio go to
Build
>Clean Project
. -
Run your app and make sure that everything is working. If you run into any trouble it is worth trying to clean your caches and restart Android Studio.
- In Firebase Console go to
Authentication
>Sign In Method
and enable Google. You will be prompted to enter your Web Client ID and Web Client Secret. These can be found in your Google Cloud Console