Sto provando a verificare un backend idToken. L'utente si è connesso con successo al lato client Firebase ma quando provo a verificare l'IDToken sul mio backend ricevo questo messaggio di errore non molto utileIl token ID autore di Firebase ha una richiesta "aud" errata
messaggioFirebase Auth ID token has incorrect "aud" claim
L'errore sembra essere diventato un po 'più informativo, e foruncoli verso il basso per non avere il nome del progetto nella chiave di autenticazione:
Error: Firebase ID token has incorrect "aud" (audience) claim. Expected "stripmall-0000" but got "617699194096-0aafcvsml0gke61d6077kkark051f3e1.apps.googleusercontent.com". Make sure the ID token comes from the same Firebase project as the service account used to authenticate this SDK. See https://firebase.google.com/docs/auth/server/verify-id-tokens for details on how to retrieve an ID token.
Chiunque abbia la minima idea di quello che potrebbe essere sbagliato? Ricevo il tokenId correttamente dal client in modo che non dovrebbe essere un problema. Approcci sinceri se questo è stato chiesto prima o è banale in qualsiasi altro modo.
firebase.initializeApp({
serviceAccount: {
"type": "service_account",
"project_id": <project id here>,
"private_key_id": <key id goes here>,
"private_key": <key goes here>
"client_email": <email goes here>,
"client_id": <my client id>,
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": <url goes here>
},
databaseURL: <my db url here>
});
router.post("/verify", function (req, res) {
firebase.auth().verifyIdToken(req.body.idToken).then(function (decodedToken) {
var uid = decodedToken.sub;
res.send(uid);
}).catch(function (error, param2) {
console.log(error); // 'Firebase Auth ID token has incorrect "aud" claim'
});
});
Da quello che capisco, 'aud' è per" pubblico "e in questo caso si riferisce all'ID del progetto. Sei sicuro di avere il project_id corretto lì? –
Beh, sono stati passati direttamente dal file json che hai scaricato, quindi non posso immaginare che ci sarebbe qualcosa di sbagliato in quello ... – Faustus
Sto vedendo anche questo costantemente sbagliato. Ottiene un ulteriore messaggio che dovrebbe essere la chiave del mio pubblico. –