问题描述
我在 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)))