最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Google authentication failed: Firebase ID token has incorrect "aud" (audience) claim - Stack Overflow

programmeradmin2浏览0评论

I’m encountering an issue with Firebase authentication on my backend. My frontend team and I are using Firebase Authentication to authenticate users with Google, but I’m getting the following error:

Google authentication failed: Firebase ID token has incorrect "aud" (audience) claim. Expected "bitpic" but got "1018060832031-v397dko55bp73mgr6r35hbvfkellsc7e.apps.googleusercontent". Make sure the ID token comes from the same Firebase project as the service account used to authenticate this SDK. See for details on how to retrieve ID token.

What I’ve Tried:

  • Verified that the frontend is sending the correct token to the backend.
  • Checked that both the frontend and backend are using the same Firebase project.
  • Consulted the Firebase documentation, but still unable to resolve the mismatch.
cred = credentials.Certificate(settings.FIREBASE_ADMIN_SDK_PATH)
firebase_admin.initialize_app(cred)
print("Current App Name:", firebase_admin.get_app().project_id)


async def verify_google_token(id_token: str):
    try:
        decoded_token = auth.verify_id_token(id_token)
        return decoded_token
    except Exception as e:
        raise_http_exception(400, f"Google authentication failed: {str(e)}")

This function is meant to verify the ID token received from the frontend. However, I’m seeing the error about a mismatch in the audience (aud) claim between the token and my Firebase project.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论