firebase-cpp-sdk: Auth: GetToken() generates invalid token (Firebase ID token has invalid signature)

This error is likely to be related to https://stackoverflow.com/questions/44014877/firebase-id-token-has-invalid-signature in 2017.

  • I am using the C++ client SDK, targetting Android platform
  • I properly get a token that contains good information (when checked with https://jwt.io/)
  • This token’s provider is Google Sign In
  • As reported on the above StackOverflow question, Email & Password provider generates a proper token
  • I have an HTTPS Cloud Function that verifies this token using admin.auth().verifyIdToken()
  • An exception is generated when I verify any token from the client, with the following message: Firebase ID token has invalid signature. See https://firebase.google.com/docs/auth/admin/verify-id-tokens for details on how to retrieve an ID token.

I have tried to manually verify the token, and I could not verify the token to match any keys I could find. I have tried the following keys:

I believe this is a bug, not a temporary issue. And I also believe this is a supported use-case, so it needs to be fixed. As reported by the StackOverflow question, this also applies to Unity.

Thanks.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (3 by maintainers)

Most upvoted comments

My issue was because the id token printed out in dart console is truncated to 1000 characters. No issue on the SDK. It was just dart didnt print full token so half of the siganture is not printed out

@a-maurice I have just started using firebase auth with a flutter application and I am running into exactly the same problem. It appear (in my case) that the token is missing part of the signature portion of the JWT.

The first token below was created in the flutter application using: https://github.com/flutter/plugins, the second was created using the web client: https://github.com/firebase/firebase-js-sdk

eyJhbGciOiJSUzI1NiIsImtpZCI6ImZmMWRmNWExNWI1Y2Y1ODJiNjFhMjEzODVjMGNmYWVkZmRiNmE3NDgiLCJ0eXAiOiJKV1QifQ.eyJuYW1lIjoiSnVzdGluIFd5ZXIiLCJwaWN0dXJlIjoiaHR0cHM6Ly9saDMuZ29vZ2xldXNlcmNvbnRlbnQuY29tLy1GQjhMbERoRlNVOC9BQUFBQUFBQUFBSS9BQUFBQUFBQUJtQS9ubGotRXd5NGx1QS9waG90by5qcGciLCJpc3MiOiJodHRwczovL3NlY3VyZXRva2VuLmdvb2dsZS5jb20vc3VzdS1kZXYiLCJhdWQiOiJzdXN1LWRldiIsImF1dGhfdGltZSI6MTU1NDEzMTI3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