Always getting invalid signature in jwt.io

后端 未结 1 1276
借酒劲吻你
借酒劲吻你 2021-01-12 14:49

I always get invalid signature when I input the generated token in jwt.io Here is my code for making the token

const secret = \'secret\';
const token = jwt.s         


        
相关标签:
1条回答
  • 2021-01-12 15:17

    If you are using jsonwebtoken lib, I tried and able to create the token and verify as well. Please have a look at the code and let me know in comments if you are still facing the issue.

    var jwt = require('jsonwebtoken')
    
    const secret = 'secret';
    const token = jwt.sign({
            username: "",
            userID: 1
        },
        secret, {
            expiresIn: "1hr"
        },
        function(err, token) {
            if (err) {
                console.log(err);
            } else {
                console.log(token);
            }
        });
    

    Here is the link of jwt.io where I entered your secret used and it's saying verified.

    https://jwt.io/#debugger-io?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IiIsInVzZXJJRCI6MSwiaWF0IjoxNTI4NTUyMDYyLCJleHAiOjE1Mjg1NTU2NjJ9.raL79zTGONyXgr9vuXzAyMflHJ0JqPYTXsy9KwmlXhA

    0 讨论(0)
提交回复
热议问题