如何在后端使用Firebase云功能将身份验证中间件与直接功能调用一起应用

时间:2019-03-13 14:15:44

标签: firebase firebase-authentication google-cloud-firestore google-cloud-functions middleware

我正在将直接函数调用与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中间件与这些类型的功能一起使用,如果方向错误,请纠正我

预先感谢

1 个答案:

答案 0 :(得分:1)

在没有任何响应之后,我决定使用HTTP请求进行函数调用,因为身份验证的状态很不错,但仍然是我的问题的欢迎解决方案。

相关问题