I am building a React-Native application with expo and test it with expo-go. I need to authenticate users to Firebase using Google.
I managed to authenticate users in Firebase with email+password, but not with Google.
I have spent several days looking for solutions on the web (and Stack-Overflow) and could not find anything definite or an example that actually works.
The proposed methods were: ‘signInWithRedirect’ and ‘signInWithPopup’ (both do not work in React-Native), ‘expo-google-sign-in’ (deprecated) and ‘Expo-auth-session’ (seems to be the latest method, but many claim it does not work with expo-go).
Is what I try to do even possible? is there a working example anywhere?
Otherwise, what would be the recommended way to authenticate users with Google in Firebase in my application (e.g., use builds instead of expo-go, or use Expo Dev Clients to enhance expo-go, etc.) – any working example please?
Many thanks in advance, I am getting desperate 🙂
2
Answers
After spending a ridiculous amount of time on this (about a week) I finally gave up and moved to React-Native CLI instead of Expo. In just a few hours, using the React-Native-Firebase package (that uses native code) I had no problems authenticating with Google.
(BTW - I tried to use React-Native-Firebase in a dev-client, but was not able to make it work)
I managed to get firebase google auth working through Expo Go using Expo SDK 47. With the release of Expo SDK 48 in February 2023, I believe it is no longer possible to get it working with Expo Go. See explanation of the SDK 48 updates here.
I was reluctant to migrate to Expo Dev Clients, but it went smoother than anticipated, so I would recommend biting the bullet and moving forward with Expo Dev Client. I believe you will need a paid apple developer account to create the builds. The other issue I’m having with this method, is that I cannot seem to get the authentication flow working in a preview build, although it works fine in the development build. See my question here which has my code sample embedded, which works with the development build.