This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-18
Channels
- # announcements (5)
- # aws (14)
- # babashka (5)
- # beginners (39)
- # brompton (9)
- # chlorine-clover (10)
- # cider (2)
- # clj-kondo (107)
- # cljfx (2)
- # cljsrn (7)
- # clojure (40)
- # clojure-australia (2)
- # clojure-conj (5)
- # clojure-europe (11)
- # clojure-japan (2)
- # clojure-nl (3)
- # clojure-spec (1)
- # clojure-uk (6)
- # clojurescript (8)
- # cursive (20)
- # datahike (6)
- # degree9 (2)
- # deps-new (2)
- # development-containers (11)
- # fulcro (26)
- # jobs (1)
- # joker (1)
- # kaocha (1)
- # lambdaisland (1)
- # malli (6)
- # membrane (1)
- # nbb (1)
- # news-and-articles (2)
- # off-topic (3)
- # pedestal (23)
- # re-frame (19)
- # reagent (6)
- # sci (110)
- # shadow-cljs (7)
- # tools-deps (9)
- # xtdb (20)
Hi. I am trying to hook into AWS Cognito to exchange an authorization code for an id_token using #pedestal I have found that I can cobble something together using raw `org.eclipse.jetty.client.HttpClient` like this
(defn logged-in [request]
(println "logged-in")
(prn request)
(let [cli (doto (HttpClient. (SslContextFactory$Client. true)) (.start))
req (doto
(.POST cli "")
(.content (FormContentProvider.
(doto (Fields.)
(.add "grant_type" "authorization_code")
(.add "client_id" "*****")
(.add "code" (get-in request [:params :code]))
(.add "redirect_uri" ""))))
)
^ContentResponse cr (.send req)
]
(clojure.pprint/pprint cr)
(println (.getContentAsString cr))
but this seems a bit ugly
but I don't want to introduce a new `clj-http` library just to extract id_token;
mostly I am using `com.cognitect.aws/api` libraries
Is that a cognitect api library function that will exchange authorization codes for id_tokens (that I've not found)?
Is there some more elegant way to run this code?
I imagine it must be a fairly common thing to do...
(cross-posted from #pedestal without waiting very long... hope that's ok)cognitect aws-api
only deals with AWS service APIs -- anything like oAuth is like an application level thing
(same thing interacting with ECR -- creating ECR repos is an amazon api, but using the docker registry that it created is an application thing)
@ben.hammond You could use the http client that cognitect/aws-api uses? https://github.com/cognitect-labs/aws-api/blob/master/deps.edn#L10 I'm not sure if the client was ever documented.
I did consider it for 10 mins
Jetty one or the new java one is fine
@ghadi What ever happened with the cognitect http-client? I vaguely recall hints that it would be open sourced at some point. Is that still the eventual plan?
It is open source - the source is in the jar
Hmm, I thought it originally was licensed such that it wasn't open source. Are there plans to publish it as a project with documentation?
it has always been open source afaik. I do not think there are any plans to publish it as a project (but not really my area)
all versions on Maven central include source, and it's licensed Apache 2