Where to create OAuth users with cemerick / friend in Clojure
1 answer
It is right. credential-fn
from one of my projects now looks something like this:
(defn linkedin-auth [{access-token :access-token :as m}]
(let [options {:query-params {:oauth2_access_token access-token
:format "json"}}
account-info (http-json "https://api.linkedin.com/v1/people/~" options)
email (http-json "https://api.linkedin.com/v1/people/~/email-address" options)]
(register-or-load-from-db
{:roles #{::user}
:identity email
:name (str (:firstName account-info) " " (:lastName account-info))}))))
And the workflow configuration:
(oauth2/workflow {:client-config linkedin-client-config
:uri-config linkedin-uri-config
:credential-fn #'linkedin-auth
:login-uri "/linkedinlogin"})
+2
source to share