Firebase云功能验证自定义令牌授权

时间:2019-02-22 01:33:42

标签: node.js firebase firebase-authentication google-cloud-functions

我正在从运行PHP的服务器上使用HTTP调用Cloud Function请求。

在我的PHP服务器上,我正在使用我的service_account js文件创建一个自定义Firebase令牌,并将其与调用该函数的HTTP请求一起发送给Bearer标头。我正在为此使用Google Client。

如何从我的Cloud Function应用程序中验证该令牌?

我的云功能如下:

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();


// CORS Express middleware to enable CORS Requests.
const cors = require('cors')({
  origin: true,
});


exports.findCommonNumbersRequest = functions.https.onRequest((req, res) => {
    //I need to verify the request here

});

我需要 firebase-admin ,因为在其他功能中,我使用admin.firestore()来读取/写入我的firestore数据库。

我知道我应该使用signInWithCustomToken(),但是由于firebase-admin不包含它,所以我无法使用它。

0 个答案:

没有答案