トークンを使用してFirebaseのカスタム認証方法を理解しようとしていますが、ドキュメントがすべて私にはわかりません。Firebase:REST経由でトークンを取得し、signInWithCustomTokenを使用する
1)まずバッシュでは、::私はJWTジェネレータで遊んでみました前に、私はjavascriptを経由してWebクライアントにログインするための認証応答トークンを使用する方法があるかどうかを確認したかった
curl 'https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?key=[theapikey]' -H 'Content-Type: application/json' --data-binary '{"email":"[the-user-email]","password":"[the-user-valid-password]","returnSecureToken":true}'
2)応答:
{
"kind": "identitytoolkit#VerifyPasswordResponse",
"localId": "<theresponse-localid>",
"email": "<theresponse-user-email>",
"displayName": "<theresponse-displayname>",
"idToken": "<theresponse-idtoken-string>",
"registered": true,
"refreshToken": "<theresponse-refreshToken>",
"expiresIn": "3600"
}
3)だから私は、JavaScriptのオブジェクトに結果をコピーします。
var token = {
"kind": "identitytoolkit#VerifyPasswordResponse",
"localId": "<localid-string>",
"email": "<user-email>",
"displayName": "<user-displayname>",
"idToken": "<idtoken-string>",
"registered": true,
"refreshToken": "<refreshtoken-string>",
"expiresIn": "3600"
};
4)私は検証のためにトークンの使用を試すためにこれらのそれぞれを試してみました:
"Object { code: "auth/invalid-custom-token", message: "The custom token format is incorrect", stack: "" }"
私は明らかに間違っていますが、ほとんどのドキュメント:
firebase.auth().signInWithCustomToken(token).catch(function(error) {
console.log("firebase.auth().signInWithCustomToken() Error: ");
console.log(error);
}
firebase.auth().signInWithCustomToken(JSON.stringify(token)).catch(function(error) {
console.log("firebase.auth().signInWithCustomToken() Error: ");
console.log(error);
}
firebase.auth().signInWithCustomToken(token.idToken).catch(function(error) {
console.log("firebase.auth().signInWithCustomToken() Error: ");
console.log(error);
}
5)それぞれについて、私はこれと同じエラーが出ますカスタムJWTトークンの作成について説明しました。私はまだ分かりません。
あなたの正確な質問は何ですか? –
私はREST APIを使ってfirebase.auth()でユーザーを認証するためにJavaScriptで使用できるトークンを生成したいと考えていました。signInWithCustomToken(トークン) – orellabac