Firebase auth / invalid-custom-token

I am trying to create custom tokens using firebase admin sdk

const uid = '91f0bf4c-3e3c-441c-a21d-6a7fee341db5'
firebaseAdmin.auth().createCustomToken(uid)

Custom tokens sometimes work with this particular uid, in other cases, when using authWithCustomToken () on the client side, I get this error:

"Auth / invalid token order" Invalid user token format. Please check the documentation.

Is it possible to debug what happens with the token? On the surface, both “good” tokens and “bad” tokens look the same:

They have 3 parts separated by a symbol .

  • The first part is 36 characters long, and in the working case and in the broken case it is the same
  • In both examples, the second part is 392 characters, and they are almost exactly the same
  • Both examples, the third part - 342 characters, and they are different.
+5
2

. Firebase SDK : auth/invalid-custom-token , .

, , , , , jtw decode "exp" .

+2

https://jwt.io . :

{
  "uid": "some-uid",
  "iat": 1500147255,
  "exp": 1500150855,
  "aud": "https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit",
  "iss": "firebaseserviceaccount@YOUR_PROJECT_ID.iam.gserviceaccount.com",
  "sub": "firebaseserviceaccount@YOUR_PROJECT_ID.iam.gserviceaccount.com"
}

YOUR_PROJECT_ID .

+3

Source: https://habr.com/ru/post/1682622/


All Articles