Saturday, 27 May 2017

How to get "kid" field of the nJwt token header

I am using nJwt to create token and using multiple signing key to create token.

My question is, when client send token, how to get "kid" field? when i decode the token, it can not be parsed using JSON.parse(token)

So this is my create token code

var claims = {
    iss: _env.domainName,  // The URL of your service
    sub: data._id,    // The UID of the user in your system
    scope: "self, users"
}

var jwt = nJwt.create(claims,signingKey);
jwt.header.kid = new Date().getTime();

console.log(__filename, jwt)

var token = jwt.compact();



via Fasalir Rahman

No comments:

Post a Comment