我正在尝试使用 python 的 firebase admin sdk 来制作自定义令牌并在测试我的应用程序时验证这些令牌。问题是,当我尝试验证令牌时,我总是收到这样的错误:
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.
Run Code Online (Sandbox Code Playgroud)
我按照指南创建应用程序并制作令牌:
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)
Run Code Online (Sandbox Code Playgroud)
在这里我得到了错误。_TokenGenarator 似乎是使用从错误中返回的默认值进行初始化的。我认为在传递应用程序时它应该自动更改这些内容,但它没有发生。我错过了什么吗?