I'm feeling extremely frustrated and in need of assistance. My goal is to authenticate a user using Google authentication so they can log in or sign up. Everything worked perfectly during development on localhost, but once I hosted my app, it stopped functioning and I encountered this error:
FirebaseAuthError: Decoding Firebase ID token failed. Ensure that you passed the complete JWT string representing an ID token. Refer to https://firebase.google.com/docs/auth/admin/verify-id-tokens for information on retrieving an ID token.
To address this, I initialized firebaseConfig and set everything up on the front-end. However, I am facing issues on the back end. I downloaded my JSON token and added it as follows:
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'
The file serviceKey.json contains important details like project_id, private_key_id, and more.
What could be going wrong? Why is it not working in production? What steps am I missing?
I believe the frontend is functioning properly with no errors, yet I encounter this issue when attempting authentication.