this is getting really frustrating for me so I am asking for your help.
What I am doing is basically just want to authenticate a user with google authentication, so user can log in or sign up. Everything went well while I was doing localhost development, now I hosted my so called app and it does not work I am getting this:
FirebaseAuthError: Decoding Firebase ID token failed. Make sure you passed the entire string JWT which represents an ID token. See https://firebase.google.com/docs/auth/admin/verify-id-tokens for details on how to retrieve an ID token.
So what I did was this: I initialized firebaseConfig and everything on the front-end.
Now on the back end I am having problems, I downloaded my JSON token , and added it like that:
import * as firebaseAdmin from 'firebase-admin';
var serviceAccount = require("../serviceKey.json");
firebaseAdmin.initializeApp(
{
credential: firebaseAdmin.credential.cert(serviceAccount)
});
export const db = firebaseAdmin.firestore();
export const auth = firebaseAdmin.auth();
codePrefix: 'auth'
serviceKey.json is where I am having the object things like project_id,private_key_id and so on.
What am I doing wrong? How come I cannot make this work in production? What else do I need to do.
I assume the frontend works well, no errors there just when about to make an authentication this happens.
Okay so I figured out what was the problem, I deployed both my front and my backend separately to Heroku, I initially wanted to host it on firebase but it is no longer free, so long story short I had to authorize my domain on the frontend in
firebase console -> authentication->sign-in method->Authorized domains.
After that it worked ,hope it helps someone.