2017-12-14 11 views
1

idTokenがサーバ上のクライアントから送信されたことを確認するにはどうすればよいですか?firebase verify idトークン:Firebase IDトークンに不正な「iss」があります

私はdocs hereの後にpythonを使用しています。基本的には、emailpasswordを返して、idTokenを返したクライアントにサインインしました。その後、idTokenをサーバーに送信して検証しますが、以下のようなエラーが表示されます。

ValueError: Firebase ID token has incorrect "iss" (issuer) claim. Expected " https://securetoken.google.com/myproject " but got " https://identitytoolkit.google.com/ ". Make sure the ID token comes from the same Firebase project as the service account used to authenticate this SDK. See https://firebase.google.com/docs/auth/admin/verify-id-tokens for details on how to retrieve an ID token.

私は、クライアントと同じプロジェクトでサービスアカウントjsonを生成したと確信しています。誰が問題になるかも知っていますか?

マイServerのコードは次のようになります。

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) 

答えて

0

私がクライアント側で間違ったドキュメントを追ったようです。最終的に私はthis docsをフォローし、次のコードを使用して、検証のためにバックエンドに送信したidTokenを抽出しました。

関連する問題