gpt4 book ai didi

clojure - 在 Clojure 中使用 cemerick/friend 在何处创建 OAuth 用户

转载 作者:行者123 更新时间:2023-12-02 01:45:12 24 4
gpt4 key购买 nike

我终于在我的 Clojure Compojure 项目上获得了适用于 Twitter 和 Facebook 登录的 OAuth 工作流,但我需要处理新用户。我应该在 Friend 工作流的哪个位置创建数据存储中不存在的用户?也许在 credential-fn 中?

最佳答案

没错。我的一个项目中的 credential-fn 现在看起来像这样:

(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))}))))

和工作流配置:

(oauth2/workflow {:client-config linkedin-client-config
:uri-config linkedin-uri-config
:credential-fn #'linkedin-auth
:login-uri "/linkedinlogin"})

关于clojure - 在 Clojure 中使用 cemerick/friend 在何处创建 OAuth 用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26094980/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com