【发布时间】:2017-08-06 18:27:03
【问题描述】:
我正在尝试使用自定义身份验证来向 Firebase 验证用户。按照文档中的指导创建 jwt 令牌。但是在发送令牌后我得到了这个响应
firebase.auth().signInWithCustomToken(response.body).catch(function (error) {
// Handle Errors here.
console.log(error)
})
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "INVALID_CLAIMS"
}
],
"code": 400,
"message": "INVALID_CLAIMS"
}
控制台
代码:“身份验证/内部错误”,消息: "{"error":{"errors":[{"domain":"global","reason":"i...CLAIMS"}],"code":400,"message":"INVALID_CLAIMS"}}"
我的 jwt 令牌格式也正确。
用于生成jwt令牌的php代码
public function authFirebase() {
$now_seconds = time();
$payload = [
"iss" => $this->service_account_email,
"sub" => $this->service_account_email,
"aud" => "https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit",
"iat" => $now_seconds,
"exp" => $now_seconds+(60*60), // Maximum expiration time is one hour
"uid" => \Auth::user()->id,
"claims" => array()
];
return JWT::encode($payload, $this->private_key, "RS256");
}
【问题讨论】:
标签: php firebase firebase-authentication