which way is the correct one for decoding tokens in the client side that are encoded using the node jsonwebtoken module, this is how am creating the token
(哪种方法是用于解码使用节点jsonwebtoken模块编码的客户端中的令牌的正确方法,这就是创建令牌的方式)
let token = jwt.sign({
my_data: data,
exp: parseInt(expiry.getTime() / 1000)
}, "SECRET");
res.status(200).json({jwt_token: token });
And in the client side, I save the token using localStorage like:
(在客户端,我使用localStorage保存令牌,例如:)
let token = server_response_token;
window.localStorage.setItem('client_token', token );
And then I try to decode the token from the local storage like:
(然后,我尝试从本地存储中解码令牌,例如:)
let payload = window.localStorage.getItem('client_token').split('.')[1];
let decoded = window.atob(payload);
But with that I am getting an error:
(但是与此同时我得到一个错误:)
Uncaught DOMException: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.
Where am I going wrong here, thanks.
(我在哪里错了,谢谢。)
ask by Teebo translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…