Fork me on GitHub
#yada
<
2016-10-01
>
bbss08:10:08

I'm trying to get oAuth2 to work following the example in the repo. I'm running into an error :cause "Context does not contain a :uri-for entry", Googling that sends me here: https://clojurians-log.clojureverse.org/yada/2016-08-23.html Where the advice was to use vhosts-model. Which seemed to work for the person asking there. But doesn't seem to work for me.

malcolmsparks09:10:44

First, you need to use yada.yada/uri-for ? You need to be using the vhosts setup in bidi, and edge shows how to do this (bidi needs to know the vhosts involved in order to generate full URLs).

malcolmsparks09:10:01

I suggest comparing your existing solution with edge's and seeing were you've deviated

kardan11:10:01

@bbss I seem to remember that I tried to use the “context" from a fn (defn index [ctx] (prn (uri-for ctx …) “Hello”) that didn’t work, but if I used resource the ctx passed to the response fn contained uri-for

kardan11:10:23

(but I’m making this up a bit, so you’ll have to test)

malcolmsparks13:10:22

the request context (that gets passed to your response functions, and most callback functions, interceptors, etc.) is the thing to pass into yada.yada/uri-for

bbss13:10:45

This is what I had so far. Maybe something wrong with my routes? I am using the yada.yada/uri-for and vhosts-model.

bbss13:10:02

(those were not important client id and secrets 😅)

kardan13:10:41

What I was going for was that (build-routes) can’t be

(defn build-routes [] 
[“/“ [[“” (fn [ctx] (uri-for ctx]))]]]
)

kardan13:10:50

Probably messed up parens

kardan13:10:12

At least that was my guess

bbss13:10:24

@kardan Hmm, the nested [[route fn][route fn]] you mean?

bbss13:10:27

Let me check.

kardan13:10:53

No, what I’m trying to say (not so well) is that instad of the (fn [ctx] …) you should have a (yada/resource …) to use uri-for

kardan13:10:01

Not sure I make sense

kardan13:10:12

Or if I’m correct so maybe I should shut up

bbss13:10:37

The response needs to be a resource?

kardan13:10:51

I think so

kardan13:10:07

But again. I’m on thin ice

bbss13:10:05

Oh any help is appreciated! 😄

bbss13:10:53

I have been looking at yada and bidi for a while but not really gotten dirty with it yet, so could be very basic things I'm missing.

bbss13:10:06

@kardan do you have an example that uses a yada resource for a response? All the examples I'm seeing are wrapping a map.

kardan13:10:51

(def not-found
  (resource
   {:id :resource/not-found
    :methods
    {:get
     {:produces "text/html"
      :response (fn [ctx]
                  (str
                   "<html><body><p>"
                   "<a href='”(uri-for ctx :resources/home)”’>Home page</a>"
                   "</p></body></html>"))}}}))

kardan13:10:24

Where there is another resource with the id :resources/home

kardan13:10:12

I hope that works, I ripped it from a toy project and tried to remove as much cruft as possible

bbss13:10:02

Hmm, my login route that has the yada.yada/uri-for function is a resource right? That's the endpoint that throws the error.

kardan14:10:40

Ok I have to admit that I missed your code sample (sorry a bit unfocused on my side). The only difference I see between your resources and mine is that I have a top level with the methods

kardan14:10:52

But I have no idea if that will help with anything

kardan14:10:34

Maybe I just confused you.

bbss14:10:00

No, I don't feel more confused than usual hahah. Thanks having looked into it anyway 🙂.