Search code examples
jwtclojurescriptauth0

How to decode JSON web token in clojurescript?


I've seen libraries like buddy and even clj-jwt but these all are used for clojure. If I can use those libraries I can't figure out how to do it in my clojurescript application.

I'm able to include the files in the project.clj under the :dependencies with something like:

[buddy/buddy-core "0.13.0"]
[clj-jwt "0.1.1"]

But then I can't call them in my cljs files. I suspect this is because they are clj files.

I was able to get the id token from the auth0 callback but now can't figure out how to read the token! Thanks for any help!


Solution

  • Use the Google Closure Crypt packages. (https://github.com/google/closure-library/tree/master/closure/goog/crypt)

    Here is an example where I used Md5 specifically (nothing to do with auth0, just showing how to use the crypt stuff. https://github.com/timothypratley/snakelake/blob/master/src/snakelake/view.cljs