0
私はfirebaseのユーザーを認証するためにカスタム認証を使用しようとしています。ドキュメンテーションのガイドとして作成されたjwtトークン。しかし、トークンを送信した後、私はこの応答を取得していFirebaseのカスタム認証が失敗する400
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"
}
コンソール
コード: "AUTH /内部エラー" のメッセージ: "{" エラー ":{" エラー ":[ { "ドメイン": "グローバル"、 "理由" "私... CLAIMS"}]、 "コード":400、 "メッセージ": "INVALID_CLAIMS"}}」
マイJWTトークンが正しいもありますフォーマット。
PHPコードを使用する代わりにJSON配列を、JSONオブジェクトが含まれている必要があり、カスタムトークン内JWTトークン
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");
}