【问题标题】:Error: Invalid token signature: token_here错误:无效的令牌签名:token_here
【发布时间】:2020-10-24 11:18:30
【问题描述】:

错误:无效的令牌签名:token_here 在 OAuth2Client.verifySignedJwtWithCertsAsync (E:\Node\node_modules\google-auth-library\build\src\auth\oauth2client.js:562:19) 在 processTicksAndRejections (internal/process/task_queues.js:94:5) 在异步 OAuth2Client.verifyIdTokenAsync (E:\Node\node_modules\google-auth-library\build\src\auth\oauth2client.js:392:23) 在异步验证 (E:\Node\app.js:6:20)

const verified = await crypto.verify(cert, signed, signature);
  if (!verified) {
    throw new Error('Invalid token signature: ' + jwt);
}

在 google-auth-library 节点 js 中的这些行上出现错误

令牌是在flutter上使用googleAuthentication获取的。

这里是Node的代码sn-p

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);
}

我在 Flutter 应用程序中获得的令牌 -

final GoogleSignInAuthentication googleAuth =
await currentUser.authentication;
googleAuth.idToken;
googleAuth.accessToken;

【问题讨论】:

    标签: node.js flutter google-signin


    【解决方案1】:

    在我的情况下,它是一个空白空间,我收到 Bearier TOKEN_HERE,Bearier 和 TOKEN_HERE 之间有一个空格,删除该空间对我有用。

    【讨论】:

      猜你喜欢
      • 2018-07-22
      • 2020-06-21
      • 2017-03-28
      • 1970-01-01
      • 2021-06-21
      • 2017-05-30
      • 2017-10-15
      • 2017-10-16
      • 1970-01-01
      相关资源
      最近更新 更多