JWT - techniq/wiki GitHub Wiki

Quick decode payload of token

var token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL3NhbXBsZXMuYXV0aDAuY29tLyIsInN1YiI6ImZhY2Vib29rfDEwMTU0Mjg3MDI3NTEwMzAyIiwiYXVkIjoiQlVJSlNXOXg2MHNJSEJ3OEtkOUVtQ2JqOGVESUZ4REMiLCJleHAiOjE0MTIyMzQ3MzAsImlhdCI6MTQxMjE5ODczMH0.7M5sAV50fF1-_h9qVbdSgqAnXVF7mz3I6RjS6JiH0H8';
var payload = JSON.parse(atob(token.split('.')[1]))

Token expiry

new Date(JSON.parse(atob(localStorage.access_token.split('.')[1])).exp * 1000)

Curl examples

Simple login (probably returns JSON with "token" property)

curl -i -X POST -d username=test -d password=test "http://localhost:8080/auth/login"

Send token in request

curl -i -X POST -H "Authorization: bearer JWT_TOKEN" "http://localhost:8080/api/v1/restricted"

Helpful site

http://jwt.io/

Libraries

Reference

PKCE