How to call a function read from an EDN file?

78 views
Skip to first unread message

Christopher Lee

unread,
Mar 12, 2018, 7:06:35 PM3/12/18
to Clojure

Clojure noob here.

After reading in the google-creds.edn file like so:

"(edn/read-string (slurp "config/google-creds.edn"))"

How do I call the function get-auth-map on this EDN file, along with the OAuth scope (["https://www.googleapis.com/auth/calendar"]) ?

Simon Luetzelschwab

unread,
Mar 13, 2018, 3:47:01 AM3/13/18
to clo...@googlegroups.com
Hey Christopher,

Welcome to the wonderful world of Clojure and we're glad to have you!

It appears you are trying to authenticate using Google's OAuth library and are currently using the google-apps-clj wrapper.

You have to either keep a reference to the return value of reading in the config file that you can pass as the first argument to the function google-apps-clj.credentials/get-auth-map or just pass (edn/read-string (slurp "config/google-creds.edn")) as the first argument directly. 

While I haven't used the library myself, here's how I would do steps 8, 9 and 10 in the REPL -

(let [config "config/google-creds.edn"
      creds (edn/read-string (slurp config))
      auth-map (google-apps-clj.credentials/get-auth-map creds scopes)
      updated-creds (assoc creds :auth-map auth-map)]
  (spit config (pr-str updated-creds))
  updated-creds)

I haven't tried this so forgive any typos, but it should give you the general idea.

I hope this helps and feel free to post any follow up questions you may have.

Best,
Simon

--
Alpeware LLC - 548 Market St #35286, San Francisco, CA 94104 - +1 415 200 3094
Reply all
Reply to author
Forward
0 new messages