如何在后端使用firebase云函数应用直接函数调用的认证中间件

问题描述 投票:2回答:1

我正在使用带有firebase云功能的直接函数调用,并希望使用令牌为后端服务器验证每个函数

  • 不使用像firebase这样的HTTP端点提供示例函数here
  • 调用下面的所有函数

`

const functions = require('firebase-functions');
const admin = require('firebase-admin');
exports = module.exports = functions.https.onRequest((req, res) => {
    if (req.method !== 'GET') {
        return res.status(401).json({
            message: 'Method not allowed'
        })
    }
    var db = admin.firestore();
    return db.doc('channels/' + req.query.id).get()
        .then(snapshot => {
            return res.send(snapshot.data())
        })
        .catch(reason => {
            return res.send(reason)
        })
});

请告诉我如何使用具有这些类型功能的auth中间件,如果方向错误,请更正我

提前致谢

firebase firebase-authentication google-cloud-firestore google-cloud-functions middleware
1个回答
1
投票

在得不到任何响应之后,我决定使用HTTP请求进行函数调用,这些认证是非常好的状态,但仍然热烈欢迎我的问题的良好解决方案。

© www.soinside.com 2019 - 2024. All rights reserved.