2017-07-05 1 views
0

私はカスタムトークンを作成するためのpythonのfirebase admin sdkを試してみることにしています。問題は、私はトークンを検証しようとしている間、私はいつも、このようなエラーが出るということです。Firebase admin SDK Python - カスタムトークンを確認できません

ValueError: Firebase ID token has incorrect "aud" (audience) claim. Expected "my_project_id" but got "https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit". 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. 

私はアプリを作成するためのガイドに従い、トークンを作る:

import firebase_admin 
from firebase_admin import auth, credentials 

cred = credentials.Certificate('/path/to/file.json') 
app = firebase_admin.initialize(cred) 
custom_token = auth.create_custom_token('some-uid', app=app) 
auth.verify_id_token(custom_token, app=app) 

と、ここで私はエラーを取得します。 _TokenGenaratorは、エラーから戻ってくるデフォルトで初期化されているようです。私は、自動的にそれらを変更する必要がありますが、それは起こっていないアプリを渡すときに思った。何か不足していますか?

答えて

1

は、IDトークンのみを受け入れます。カスタムトークンはそのカテゴリに分類されません。このtest caseを参照してください。この場合、予想される動作はValueErrorです。

IDトークンは、client SDKから取得できます。提供されているsignInWithCustomToken()メソッドの1つを呼び出して、IDトークン用のカスタムトークンを交換できます。

+0

カスタムトークンでのログイン:https://firebase.google.com/docs/auth/admin/create-custom-tokens#sign_in_using_custom_tokens_on_clients –

関連する問題