如何向Firebase httpscallable添加标头 [英] How to add headers to firebase httpscallable

查看:53
本文介绍了如何向Firebase httpscallable添加标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的httpscallable中添加一个授权标头,以调用Firebase函数.目前,我使用:

I'd like to add an authorization header to my httpscallable for calling a firebase function. Currently I use:


const httpsCallable = Firebase.functions.httpsCallable('xxxxx');
        httpsCallable(call_args).then(....)

但是我试图确保我的应用程序需要添加身份验证令牌.如何使用"Bearer:...."添加授权标头?

But I'm trying to secure my app need to add auth tokens. How can I add an authorization header with "Bearer: ...."?

在该线程上被接受的答案只是说有可能".有人知道怎么做吗?

The accepted answer on this thread just says "it's possible." Does anyone know how to do it though?

谢谢!

推荐答案

回答我自己的问题.对于已登录的用户,firebase会自动以"Authorization:","Bearer:$ token"的形式包含Authorization标头,其中token是firebase.auth().currentUser.getIdToken()的结果

Answering my own question. For a logged in user, firebase will automatically include the Authorization header in the form "Authorization:" "Bearer: $token" where token is the result of firebase.auth().currentUser.getIdToken()

这篇关于如何向Firebase httpscallable添加标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆