Bharad Waj
Bharad Waj

Reputation: 83

In Cloud Functions not able to do firebase authentication

const functions = require('firebase-functions');
const express = require('express');
var firebase = require("firebase/app");
var firebaseauth=require("firebase/auth");
const app=express();
app.get('/',(req,res)=>{
    res.send('hello');
});
app.get('/userid',function(req,res){
    var deleted=false;

    if (firebaseauth.auth().currentUser !== null)
    {
       userid= firebaseauthc.auth().currentUser.uid;
       console.log(userid);
    }

 });
exports.app=functions.https.onRequest(app);

I have installed all the dependencies and the thing which I get when login by my email and password is TypeError: firebaseauth.auth is not a function at /Users/bharadwaj/Desktop/NewNode/functions/index.js:12:22 I have been struck here for past 1 hour. I have tried all the available methods on internet

Upvotes: 0

Views: 28

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317750

The concept of a "current user" is present in backend code that uses Firebase Authentication. A current user is only available in the frontend client. If you want a user to be able to invoke a function and identify themselves (so you can be sure they're allowed to make the request), you should send an ID token to the function, and verify it with the Firebase Admin SDK.

Read the documentation for more information and specific examples.

Upvotes: 1

Related Questions