How can I have both firebase and firebase-admin in the same project.

335 views
Skip to first unread message

Vincent Bergeron

unread,
Jul 22, 2018, 5:10:28 PM7/22/18
to Firebase Google Group
Hi!

It's a follow-up of this thread:


I need to use the client`s signInWithEmailAndPassword  in my application. Therefore, I want to use both firebase and firebase-admin SDK.

here's my dependencies:
"dependencies": {
    "express": "^4.16.3",
   "firebase": "^5.3.0",
   "firebase-admin": "5.12.1",
   "firebase-functions": "^1.1.0",
    "lodash": "^4.17.10",
   "moment": "^2.22.2",
   "moment-timezone": "^0.5.21",
   "uuid": "^3.3.2"
 }

I do:
import * as firebase from 'firebase';
const authFirebaseApp = firebase.initializeApp(firebaseConfig, `myapp`);
const firebaseAuth = firebase.auth(authFirebaseApp);


When the last line is executed, I get this error:
TypeError: firebase.auth is not a function

 
I read some posts that suggest it was a version/dependency problems, so I remove my node_module folder and reinstall everything.

I even first used firebase-admin version 5.13.0, but I got more errors:
E:\DEV\html\TuxedoBackend\functions
`-- UNMET PEER DEPENDENCY firebas...@5.13.0

npm WARN firebase-...@1.1.0 requires a peer of firebase-admin@~5.12.1 but none was installed.
npm WARN functions No repository field.
npm WARN functions No license field.
npm ERR! code 1


So what should I do to make this working?

Thanks

VB

Vincent Bergeron

unread,
Jul 22, 2018, 9:13:13 PM7/22/18
to Firebase Google Group
Well, I found a work-around...

In order to achieve what I want, I can send an Http request to validate the user and password like this:


Body:
{
      "email": "us...@email.com",
     "password": "mypassword"
}



And the response:
{
    "kind": "identitytoolkit#VerifyPasswordResponse",
    "localId": "AN_ID",
    "email": "us...@email.com",
    "displayName": "",
    "idToken": "AN_ID_TOKEN",
    "registered": true
}


But I really would like to be able to use both Client and Admin SDK in the same project...

Reply all
Reply to author
Forward
0 new messages