0
使用jsonwebtoken
https://www.npmjs.com/package/jsonwebtokenjsonwebtoken解碼返回null
var jwt = require('jsonwebtoken');
var token = httpResponse.headers["x-authorization-bearer"].trim();
var decoded = jwt.decode(token);
console.log(token); // eyJ0eXAiOiJKV1QiLCJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0.WTMwOGJudHBDTVM3Rm52clBPOGFPUQ.UbXYtb5KppbGYn3AkyOkCg.ljnC5I8q3qThn-NHY6qBqkFhSS9hNiR_pviIFB1zNVmp5Z2wOx0MON2sWRsDF__uSJ-PdI7QaM6djdflbTvKyPWbtKV6g_VDOU-lF6XKMI96BMK41mmBiJSNyDNxE5hqB4X_qWeCYMif8tf583bcKvkrxyuUTsRwvR2Xdo6yl9dyapYGhvKar2TtogOR9-jlFADfPL07ih0YjPYTo2gAWGzrVR6tNuyoRJolYd0ixon5nZ1aP5TdcbPrNcWmGfmuIfWN12BdiEtfrVYDNV7xwmNWfuxke0Uev5VAlIATg_U.1X6R6y9IK3n8NAexswUQKQ
console.log(decoded); // null
你在評論中混淆了智威湯遜嗎?如果你還沒有,在https://jwt.io/上檢查它時,它似乎不是有效的。 –
@KirkLarkin你想用密鑰解碼?因爲如果你去https://www.jsonwebtoken.io/它似乎是有效的 – WalksAway
我粘貼在jsonwebtoken.io它說無效的令牌。 –