1
votes

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;
1

1 Answers

0
votes

In my case it was an empty space, I'm receiving Bearier TOKEN_HERE, there is an space between Bearier and TOKEN_HERE, removing that space worked for me.

enter image description here