I am trying to log in to Firebase with a custom token. I followed all the steps and the decoded token would be like this, following all Google requirements:
{
"alg": "RS256",
"typ": "JWT"
}
{
"id": 397,
"uid": "397",
"email": "[email protected]",
"permission": null,
"iss": "[email protected]",
"sub": "[email protected]",
"aud": "https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit",
"type_user": "user",
"iat": 1545044517,
"exp": 1545048117
}
After fighting with the JWT I have reached a point where I get this error:
{ [Error: SIGNATURE_INVALID]
code: 'auth/invalid-custom-token',
message: 'SIGNATURE_INVALID' }
And the key is happening this way:
let token = jwt.sign(payload, keyData.private_key, { expiresIn: '3600s', algorithm: 'RS256' })
The password has the following format:
-----BEGIN RSA PRIVATE KEY-----
mi Llave Privada
-----END RSA PRIVATE KEY-----