![]() In your code you created the token using the key 'mySecretKey' and then you tried to verify it using. ![]() Its result should be false or Promise if the token should be rejected or, otherwise, be true or Promise if the token should be accepted and, considering that er will be used after that, the return should be decodedToken itself. In your example you have invalid signture and you should change this line of code: const decode jwt.verify (token,'mySecretKey') In order to verify a token you need to pass 2 parameters: The token (like you done correctly) The secrety key. blacklisting) by providing the option trusted with the following signature: (request, decodedToken) => boolean|Promise|SignPayloadType|Promise where request is a FastifyRequest and decodedToken is the parsed (and verified) token information. As 'window' object is not present in nodejs environment, we could use the following lines of code : let base64Url token.split ('.') 1 // token you get let base64 base64Url.replace ('-', '+').replace ('', '/') let decodedData JSON.parse (om (base64, 'base64'). exports = async function ( fastify, opts ) ) trustedĪdditionally, it is also possible to reject tokens selectively (i.e. Step 1 Generating a Token jsonwebtoken is an implementation of JSON Web Tokens.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |