JSON Web Tokens for Go
- Simple API.
- Optimized for speed.
- Dependency-free.
Go version 1.13
go get github.com/cristalhq/jwt
signer := jwt.NewHS256([]byte(`secret`))
builder := jwt.NewTokenBuilder(signer)
claims := &jwt.StandardClaims{
Audience: []string{"admin"},
ID: "random-unique-string",
}
token, _ := builder.Build(claims)
raw := token.Raw() // JWT signed token
See these docs.