fireship.io icon indicating copy to clipboard operation
fireship.io copied to clipboard

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

Open utterances-bot opened this issue 3 years ago • 9 comments

Google SignIn

Authenticate via OAuth with Google SignIn

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

utterances-bot avatar May 22 '22 22:05 utterances-bot

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

SBKCODER-random avatar Jun 02 '22 02:06 SBKCODER-random

cannot import firebase hence firebase is undefined.

RajGM avatar Jun 15 '22 16:06 RajGM

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]

Bungleboy avatar Jun 17 '22 01:06 Bungleboy

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

ryan-astaphan avatar Jul 12 '22 05:07 ryan-astaphan

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!

JimboTron9000 avatar Jul 21 '22 02:07 JimboTron9000

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); }

JimboTron9000 avatar Jul 21 '22 02:07 JimboTron9000

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)

justisCrocker avatar Aug 31 '22 01:08 justisCrocker

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

justisCrocker avatar Aug 31 '22 01:08 justisCrocker

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/

dmthomson avatar Sep 19 '22 20:09 dmthomson