node.js - 错误:无效的令牌签名:token_here
问题描述
错误:无效的令牌签名:token_here at 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) 6:20)
const verified = await crypto.verify(cert, signed, signature);
if (!verified) {
throw new Error('Invalid token signature: ' + jwt);
}
在 google-auth-library node js 中获取这些行的错误
令牌是在颤振上使用 googleAuthentication 获得的。
这是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);
}
我在 Flutter 应用程序中获得的令牌 -
final GoogleSignInAuthentication googleAuth =
await currentUser.authentication;
googleAuth.idToken;
googleAuth.accessToken;
解决方案
推荐阅读
- jquery - 复制选定的 div 并将其粘贴并删除
- python - 如何获取系列中的索引?
- java - 如何在我的应用程序中删除 android.permission.WRITE_EXTERNAL_STORAGE
- javascript - 在 React 中将数组的元素作为对象的一部分推送
- android - 如果我使用 Firebase 消息传递,在什么情况下我应该关注“防止自动初始化”
- android - 使用设备当前状态旋转 mapbox 指南针
- python - PyQt5 中的信号和槽
- reactjs - 如何使用 redux-axios-middleware 测试 Redux 异步操作
- django - 在 Django 中设置学年或财政年
- bash - 在 Multitech(蜂窝路由器)上获取 Mac 地址