%Id: 308

%SOId: 10161

% draft

JSON Web Tokens (JWTs) are a popular method for representing claims securely between two parties. Understanding how to work with them is important when developing web applications or application programming interfaces.

Remarks

context.Context and HTTP middleware are outside the scope of this topic, but nonetheless those curious, wandering souls should check out https://github.com/goware/jwtauth, https://github.com/auth0/go-jwt-middleware, and https://github.com/dgrijalva/jwt-go.

Huge kudos to Dave Grijalva for his amazing work on go-jwt.

Parsing and validating a token using the HMAC signing method

Creating a token using a custom claims type

Creating, signing, and encoding a JWT token using the HMAC signing method

Parsing the error types using bitfield checks

Getting token from HTTP Authorization header

Using the StandardClaims type by itself to parse a token