6
3 Comments

JWT authentication with deno

How to create and validate JSON Web Tokens in Deno

on October 15, 2020
  1. 2

    I think you forgot to post the link? Or is this a question?

  2. 1

    Note that authentication and authorization are not done by djwt. It is just a JWT library that produces a token and validates it. Therefore, don't expect to simply provide this library with a username and password. And expect everything else, including generating and validating a JWT, to be done.

    Because of that, it is very difficult to get a realistic example out of it. Unless the other portions of the flow are applied by ourselves.

    So to get started, let’s create an index.js file and import djwt library.

    import { validateJwt } from "https://deno.land/x/djwt/validate.ts";
    import { makeJwt, setExpiration } from "https://deno.land/x/djwt/create.ts";

    Notice that djwt does not do authentication and authorization. It is simply a JWT library that produces and validates a token. Don't expect to simply have a username and password for this library, therefore. And expect everything else to be completed, including generating and validating a JWT.

    Because of that, getting a realistic example out of it is very hard. Unless we ourselves apply the other portions of the flow.

    I read a useful article regarding the same: https://medium.com/@loginradius/how-to-create-and-validate-json-web-tokens-in-deno-da67c5540d6d

    I hope it would be useful to you :)