简体   繁体   English

在 Cloud Functions 中无法进行 firebase 身份验证

[英]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.我已经安装了所有依赖项以及通过 email 登录时得到的东西,密码是 TypeError: firebaseauth.auth is not a function at /Users/bharadwaj/Desktop/NewNode/functions/index.js:12:22过去 1 小时在这里被击中。 I have tried all the available methods on internet我已经尝试了互联网上所有可用的方法

The concept of a "current user" is present in backend code that uses Firebase Authentication. “当前用户”的概念出现在使用 Firebase 身份验证的后端代码中。 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. 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.阅读文档以获取更多信息和具体示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM