【发布时间】:2021-02-25 17:24:00
【问题描述】:
我在 windows 10 中运行 doom emacs,用于 clojure。基于
Sparkfund google-apps-clj.credentials/get-auth-map
功能,
_ (println "Please visit the following url and input the code "
"that appears on the screen: " auth-url)
请访问以下网址并输入屏幕上显示的代码:https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=1080463043693...www.googleapis.com/auth/spreadsheets "
给我我的 emacs repl 中的链接,然后我将链接复制并粘贴到我的浏览器中,它返回一个可复制的授权码 4/1AY0e-g5z1hqNhJtLosomecodezSnx5gEGOk。
问题是,我如何将授权码粘贴到我的 REPL 中? repl 仍然卡在 println 中,我不得不 Ctrl+C+ Ctrl+C 杀死进程。
它应该在我得到授权码后给出令牌。因为还有这段代码来完成这个功能。请帮忙?
auth-code (doto ^String (read-line) assert) token-request (doto (.newTokenRequest auth-flow auth-code) assert (.setRedirectUri "urn:ietf:wg:oauth:2.0:oob"))] (doto (.execute token-request) assert)))
(defn get-auth-map
"Given a google-ctx configuration map, and a list of scopes(as strings),
creates a URL for the user to receive their auth-code, which is then used
to receive an authorization map, which the user should store securely"
[google-ctx scope]
(let [google-secret (get-google-secret google-ctx)
auth-flow-builder (doto (GoogleAuthorizationCodeFlow$Builder. http-transport json-factory
google-secret scope)
(.setAccessType "offline"))
auth-flow (doto (.build auth-flow-builder)
assert)
auth-request-url (doto (.newAuthorizationUrl auth-flow)
assert
(.setRedirectUri "urn:ietf:wg:oauth:2.0:oob"))
auth-url (.build auth-request-url)
_ (println "Please visit the following url and input the code "
"that appears on the screen: " auth-url)
auth-code (doto ^String (read-line) assert)
token-request (doto (.newTokenRequest auth-flow auth-code)
assert
(.setRedirectUri "urn:ietf:wg:oauth:2.0:oob"))]
(doto (.execute token-request)
assert)))
【问题讨论】:
-
另一个邪恶的 Clojurian :)
-
没有人期待……黑檀之夜的明晰兄弟!
标签: oauth-2.0 emacs clojure read-eval-print-loop