Skip to content
This repository was archived by the owner on Nov 20, 2025. It is now read-only.
This repository was archived by the owner on Nov 20, 2025. It is now read-only.

Invalid token signature #987

@dpkjain

Description

@dpkjain
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.

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, // Specify the CLIENT_ID of the app that accesses the backend
    // Or, if multiple clients access the backend:
    //[CLIENT_ID_1, CLIENT_ID_2, CLIENT_ID_3]
  });
  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

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions