Firebase token error, "The custom token corresponds to a different audience."
Solution 1
I got this error too, I got that because I used a service account that was not related to the firebase project. After creating new service account with new key under the firebase project its started to work.
For creating service account you can follow the instructions here : https://firebase.google.com/docs/server/setup
Solution 2
After spending day on this .I got to know , my GoogleService-Info
was wrong. I've tried almost 20+ solution for this .
Resolved it using replacing new GoogleService-Info
from the current project in Firebase Console.
Related videos on Youtube
Admin
Updated on July 03, 2022Comments
-
Admin almost 2 years
I'm trying to generate JWT token for Firebase using Ruby on the server. Before 3.0 we used token generator but it stopped working after the upgrade. The token I get with code below gives an error:
The custom token corresponds to a different audience.
and I can't find anywhere what it means.
private_key = OpenSSL::PKey::RSA.new <<-PEM -----BEGIN PRIVATE KEY----- ..redacted.. -----END PRIVATE KEY----- PEM service_account_email = '[email protected]' now_seconds = Time.now.to_i payload = { iss: service_account_email, sub: service_account_email, aud: 'https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit', iat: now_seconds, exp: now_seconds + (60 * 60), uid: self.id.to_s, debug: true, claims: { userId: self.id, slug: self.slug, username: self.username, avatar: self.profile.avatar.url, group: self.group, debug: true } } JWT.encode payload, private_key, 'RS256'
Thanks
-
Kegham K. over 7 yearsThanks i had the same issue