Liking cljdoc? Tell your friends :D

funcade

creates, manages and refreshes oauth 2.0 jwt tokens

<! release <! clojars

usage

=> (require '[funcade.core :as f])

=> (def conf {:client-id "planet-earth"
              :scope "solar-system"
              :access-token-url "https://milky-way-galaxy/token.oauth2"
              :client-secret "super-hexidecimal-secret"})

optional config properties:

namedefaultdescription
:token-headers{:Content-Type "application/x-www-form-urlencoded"}headers passed to aquire the token
:grant-type"client_credentials"oauth 2.0 grant type
:refresh-percent10when less than % of time between expires-at and issued-at remains, refreshes the token
=> (def token-repo (f/wake-token-master :serpens conf))

=> (f/current-token token-repo)
;; "eyJhbGci...dc22w"
user=> (f/stop token-repo)
true

group many sources

=> (def sources {:mars {:client-id "..."
                        :client-secret "..."
                        :access-token-url "..."
                        :scope "..."}
                 :asgard {:client-id "..."
                          :client-secret "..."
                          :access-token-url "..."
                          :scope "..."}})

=> (def jwt (f/wake-token-masters sources))

creates two token masters:

=> jwt
;; {:mars #object[funcade.core.TokenMaster"],
;;  :asgard #object[funcade.core.TokenMaster"]}

=> (-> jwt :mars f/current-token)
;; "eyJhbGci...dc22w"

=> (-> jwt :asgard f/current-token)
;; "eyJhbRkv...id95p"

license

copyright © 2020 shvetsm

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

Can you improve this documentation? These fine people already did:
anatoly & Mark Shvets
Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close