Any way to use Google Firebase authentication in expo (create-react-native-app) without a "pull" project
As a question, to log in with Google to firebase you need to install google service, but if you create a new project with action-action-native-app initiative, it will not have "android" or "ios" folder (accept used "throw away" ) so does anyone have a suggestion for me? However, I don't even know how to set up a google service in my project (even I "throw" the project).
+3
source to share
2 answers
No need to make any changes to android or ios folders to support google firebase in Expo build app.
- Follow the guide to set up Google Authentication in Expo Docs
- Take the approach outlined in Expo Using the Firebase Guide , which describes how to authenticate with Facebook and replace Google where needed.
+2
source to share
@brentvatne's answer is a bit outdated. This is how I worked on Expo v27
Important bit: you can get client IDs from these instructions .
Just select firebase app from project dropdown on google page.
const _loginWithGoogle = async function() {
try {
const result = await Expo.Google.logInAsync({
androidClientId:"YOUR_ANDROID_CLIENT_ID",
iosClientId:"YOUR_iOS_CLIENT_ID",
scopes: ["profile", "email"]
});
if (result.type === "success") {
const { idToken, accessToken } = result;
const credential = firebase.auth.GoogleAuthProvider.credential(idToken, accessToken);
firebase
.auth()
.signInAndRetrieveDataWithCredential(credential)
.then(res => {
// user res, create your user, do whatever you want
})
.catch(error => {
console.log("firebase cred err:", error);
});
} else {
return { cancelled: true };
}
} catch (err) {
console.log("err:", err);
}
};
0
source to share