【发布时间】:2018-05-28 18:17:40
【问题描述】:
如何在服务器上验证从客户端发送的idToken?
我正在使用 python 关注docs here。基本上我用email和password在客户端登录,返回idToken,然后我将这个idToken发送到服务器进行验证,但得到如下错误。
ValueError:Firebase ID 令牌的“iss”(颁发者)声明不正确。 预期为“https://securetoken.google.com/myproject”但得到 “https://identitytoolkit.google.com/”。确保 ID 令牌来了 来自与服务帐号相同的 Firebase 项目 验证此 SDK。看 https://firebase.google.com/docs/auth/admin/verify-id-tokens 为 有关如何检索 ID 令牌的详细信息。
我很确定我在与客户端相同的项目中生成了服务帐户 json。有人知道可能是什么问题吗?
我的服务器代码如下所示:
from firebase_admin import credentials, initialize_app, auth
def is_authenticated(id_token):
cred = credentials.Certificate("service-account.json")
app = initialize_app(cred)
return auth.verify_id_token(id_token, app)
【问题讨论】:
标签: python firebase firebase-authentication