Working with JWT in Go

TL;DR:

  • If you are using github.com/lestrrat-go/jwx/v2/jwk somewhere in your code, you might as well use github.com/lestrrat-go/jwx/v2/jwt to handle your JWTs
  • It will be one less dependency, and everything works seamlessly out of the box. No extra external packages required just to load a JWK!
  • All examples below can be found in the examples directory for JWX. And there are a lot of documentation both in the repository itself, and the go doc

Parsing a JWK or JWKS

  1. Parse from a JSON []byte sequence, or
  2. Parse from a file containing the key.

Building JWTs

Accessing JWT claims

Signing JWTs

Verifying JWTs

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store