Closed kennyjwilli closed 9 years ago
You can use str->jwt
function to decode tokens.
I added sample codes to README.md (284727d)
(require '[clj-jwt.core :refer :all])
;; generate token
(def claim {:foo "bar"})
(def token (-> claim jwt (sign :HS256 "secret") to-str)) ; => eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIifQ.dtxWM6MIcgoeMgH87tGvsNDY6cHWL6MGW4LeYvnm1JA
;; decode token
(-> token str->jwt) ; => #clj_jwt.core.JWT{:header {:alg "HS256", :typ "JWT"}, :claims {:foo "bar"}, :signature "dtxWM6MIcgoeMgH87tGvsNDY6cHWL6MGW4LeYvnm1JA"}
(-> token str->jwt :claims :foo) ; => "bar"
(-> token str->jwt (verify "secret")) ; => true
Ah got it. Thanks!
Is there support for decoding tokens? If so, are there any docs for it? I have searched and searched for it and have found no such docs or functionality.