【问题标题】:Firebase ID token has incorrect "aud" (audience) claim with PythonFirebase ID 令牌对 Python 的“aud”(受众)声明不正确
【发布时间】:2018-04-24 00:15:26
【问题描述】:

使用 firebase python API,我为我的应用程序的用户 ID 创建了自定义令牌,这是为了启用验证并可能从后端请求用户数据。

这是我的示例代码:

   #create custom token with uid
    custom_token = firebase_admin.auth.create_custom_token(uid)
    print custom_token
    decoded_token = 
    firebase_admin.auth.verify_id_token(id_token=custom_token, 
   check_revoked=True)

但是我在使用 Python 的 firebase 上收到以下错误:

Firebase ID token has incorrect "aud" (audience) claim. Expected "sec-vef-sandbox" 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 ID token.

我已确保 projectId 与“sec-vef-sandbox”匹配,因此看不到错误来自何处。在查看 Stack Overflow 上的其他帖子后,它似乎是一个 firebase 错误。我想知道有没有办法解决这个问题。

【问题讨论】:

    标签: python firebase firebase-authentication google-oauth


    【解决方案1】:

    Firebase admin sdk 仅验证 ID 令牌,自定义令牌不属于此类别。所以没有解决方法,只能检查documentation 如何从客户端获取有效的 ID 令牌。此外,GitHub 上的这个帖子将更详细地说明firebase-python-admin SDK 特有的这个问题。

    【讨论】:

      猜你喜欢
      • 2020-06-20
      • 2020-06-29
      • 2016-11-15
      • 1970-01-01
      • 2020-05-06
      • 1970-01-01
      • 2020-11-05
      • 2016-12-23
      • 2015-04-09
      相关资源
      最近更新 更多