Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

courses/react-next-firebase/auth-google-signin/ #785

Open
utterances-bot opened this issue May 22, 2022 · 9 comments
Open

courses/react-next-firebase/auth-google-signin/ #785

utterances-bot opened this issue May 22, 2022 · 9 comments

Comments

@utterances-bot
Copy link

Google SignIn

Authenticate via OAuth with Google SignIn

https://fireship.io/courses/react-next-firebase/auth-google-signin/

Copy link

Im trying to run this but the if (!firebase.apps.length) {
firebase.initializeApp(firebaseConfig)
}
wont work it says it cant read properties of apps

Copy link

RajGM commented Jun 15, 2022

cannot import firebase hence firebase is undefined.

Copy link

I had the same problem as above. It seemed to be failing to find the firebase/app module and then got upset when testing for the length.

For me I was able to work around this by downgrading from firebase v9 to the v8 with the following. Things worked after that. Seems like there were breaking changes in v9 for this tutorial.

npm rm firebase
npm i [email protected]

Copy link

I'm having the same issues as the other 3 commenters. I love your videos Jeff, but this course is dated.

Copy link

Hey guys i figured it out. All you have to do is Change your imports from "import firebase from 'firebase/app' "
to "import firebase from 'firebase/compat/app' ". You have to add the compat between firebase and whatever directory you are importing from. Everything works great now! :) Best of luck!

Copy link

Also, if you close out of the authentication before you complete, you will get an error that crashes the app. All you have to do is wrap your async function in a try catch block. where you pass the error through the catch block like this.
try {
await auth.signInWithPopup(googleAuthProvider);
} catch (err) {
console.log(err);
}

Copy link

I am getting this error when trying to load /enter -- TypeError: firebase_compat_app__WEBPACK_IMPORTED_MODULE_0__.default.auth.googleAuthProvider is not a constructor
at eval (webpack-internal:///./lib/firebase.js:37:28)

Copy link

Nevermind above comment, g in google needs to be 'G'oogle.

Copy link

HEADS UP - Anyone reading this past today - Refer back to the bottom of the #8 Firebase Setup to get around teh firebase 9 errors. There's a complete write up in Github.
https://fireship.io/courses/react-next-firebase/app-next-firebase/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants