Error: Invalid token signature: token_here at OAuth2Client.verifySignedJwtWithCertsAsync (E:\Node\node_modules\google-auth-library\build\src\auth\oauth2client.js:562:19) at processTicksAndRejections (internal/process/task_queues.js:94:5) at async OAuth2Client.verifyIdTokenAsync (E:\Node\node_modules\google-auth-library\build\src\auth\oauth2client.js:392:23) at async verify (E:\Node\app.js:6:20)
const verified = await crypto.verify(cert, signed, signature);
if (!verified) {
throw new Error('Invalid token signature: ' + jwt);
}
getting the error on these lines in google-auth-library node js
The token is obtained using googleAuthentication on flutter.
Here is the code snippet of Node
const { OAuth2Client } = require('google-auth-library');
const client = new OAuth2Client(CLIENT_ID);
async function verify() {
const ticket = await client.verifyIdToken({
idToken: token,
audience: CLIENT_ID,
});
const payload = ticket.getPayload();
const userid = payload['sub'];
console.log(payload);
console.log(userid);
}
Token I am getting in Flutter application -
final GoogleSignInAuthentication googleAuth =
await currentUser.authentication;
googleAuth.idToken;
googleAuth.accessToken;