I'm using firebase for Android and IOS application. The Application has dedicated backend and verifies the Token issued by firebase after phone/email auth using verifyIdToken
method. I'm verifying the token for new user registration. The concept is working fine for android application. When new user Authenticates
, Registration API going to be called with Token issued by Firebase and I'm verifying that token using Service Account
. However, For ios it fails with the exception that kid
header is invalid. Here is the exception trace.
A key with ID "3494b1e786cdad092e423766bbe37f54ed87b22d" could not be found.
{"exception":"[object] (Firebase\\Auth\\Token\\Exception\\UnknownKey(code: 0):
A key with ID \"3494b1e786cdad092e423766bbe37f54ed87b22d\" could not be found.
at /home/fgx3uhiothty/public_html/vendor/kreait/firebase-tokens/src/Verifier.php:132)
In Firebase Auth Documentation, there is clearly stated that
kid Key ID Must correspond to one of the public keys listed at https://www.googleapis.com/robot/v1/metadata/x509/[email protected]
When I checked key 3494b1e786cdad092e423766bbe37f54ed87b22d
with the google's public key after decoding token, I didn't find the kid
matching. However, the token from ios device is issued by firebase itself after successful auth. So how is it possible having different kid
header in ios token?
I'm using kreait/firebase-tokens-php
library for accessing service account API from backend.
kid
header of the android token is correct. it happens to me with ios. This kind of bug affects the deployed system, I loose around 2k users. When I checked backend dashboard there is only 6.7k registered user and on firebase auth, the count is 8.4k. means so many users authenticated but can't be able to complete registration because of token verification error. – Kiran ManiyaFirebase Docs
is not correct. LOL – Kiran Maniyahttps://www.googleapis.com/service_accounts/v1/metadata/x509/my_firebase_service_account
– devcrazy