This is a sample of JWT using golang.
To install missing packages, simply install glide and run:
glide up
To compile the project, run
go build
There are 2 API end points, the first one accepts a JWT token. You can generate another sample here jwt.io
eyJhbGciOiJUaGlzIGlzIG15IHRva2VuIiwidHlwIjoiSldUIn0.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiZXhwIjoiMjAxNy0xMS0wNCJ9.GyjQItZyp2wbzYjMzH0C_SfTr187bv1eYnEgCkcrhYA
.
The other one generates a JWT token based on a successful login.
URL: /jwt/validate/
Request:
{
"jwt": "eyJhbGciOiJUaGlzIGlzIG15IHRva2VuIiwidHlwIjoiSldUIn0.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiZXhwIjoiMjAxNy0xMS0wNCJ9.GyjQItZyp2wbzYjMzH0C_SfTr187bv1eYnEgCkcrhYA"
}
Response:
{
"jwtValid": true
}
URL: /jwt/login/
Request:
{
"username": "user",
"password": "pass"
}
Response:
{
"jwt": 'Some JWT Token'
}