Chas,
It was the header being sent. A form post sends data as url encoded, with
header as url encoded form data, while the javascript library was posting
data as application/json, that is the reason it was failing. Also thanks
for the pointer on realm.
Thanks,
Murtaza
On Thursday, December 20, 2012 4:03:19 PM UTC+5:30, Chas Emerick wrote:
>
> Your Clojure code is correct. However, whatever you're using to produce
> the POST to /openid (i.e. this 'ng-click="signin('google')"' stuff) isn't
> behaving as you're expecting. I didn't dig into what it's actually doing,
> but a simple form posting to /openid starts that workflow with Google
> without a problem:
>
> diff --git a/public/landing.html b/public/landing.html
> index 68c4618..88bfa59 100644
> --- a/public/landing.html
> +++ b/public/landing.html
> @@ -94,7 +94,10 @@
>
> <hr class="soften">
>
> -
> + <form method="POST" action="/openid">
> + <input type="hidden" name="identifier" value="
> https://www.google.com/accounts/o8/id"/>
> + <input type="submit" value="login with google"/>
> + </form>
> </div>
>
> Note that the :realm you provide to OpenId needs to correspond to the
> domain that the site is running on; so, locally, you'll have to set that to
> e.g. http://localhost:8080, and then to http://mydomainname.com in
> production, etc.
>
> - Chas
>
> On Dec 19, 2012, at 9:56 PM, Murtaza Husain wrote:
>
>
> I have changed the parameter name to 'identifier', however I am still
> hitting the NPE, any ideas?
>
> I have placed the code on github - https://github.com/murtaza52/cfaiz.git,
> if you would like to take a look.
>
> Thanks,
> Murtaza
>
> On Thursday, December 20, 2012 12:12:27 AM UTC+5:30, Chas Emerick wrote:
>>
>> The parameter name is 'identifier' (not 'openid_identifier') by default
>> (which you can customize if you want by specifying a :user-identifier-param
>> option in openid/workflow).
>>
>> That said, the NPE you just hit has drawn my attention to an (unrelated)
>> bug in the openid workflow. Thanks! :-)
>>
>> - Chas
>>
>> On Dec 19, 2012, at 1:20 PM, Murtaza Husain wrote:
>>
>>
>> Thanks for catching that Aaron !
>>
>> The app currently redirects to the login page now. However I get an error
>> when I try to post to the "/openid" url with {"openid_identifier":"
>> https://www.google.com/accounts/o8/id"} as post data.
>>
>> Here is the updated code -
>>
>> (ns faiz.handler
>> (:use compojure.core)
>> (:require [compojure.handler :as handler]
>> [compojure.route :as route]
>> [ring.util.response :as resp]
>> [me.shenfeng.mustache :as mustache]
>> [cemerick.friend :as friend]
>> (cemerick.friend [workflows :as workflows]
>> [credentials :as creds]
>> [openid :as openid])))
>>
>> (mustache/deftemplate index (slurp "public/index-async.html"))
>>
>> (def index-data {:title "Invoize." :brand "Faiz" :links [{:url
>> "#/students" :text "Students"} {:url "#/thaalis" :text "Thaalis"}]})
>>
>> (defroutes app-routes
>> (GET "/" [] (resp/redirect "/login"))
>> (ANY "/login" [] (resp/file-response "landing.html" {:root "public"}))
>> (GET "/landing" [] (resp/file-response "landing.html" {:root "public"}))
>> (GET "/index" [] (friend/authenticated (index index-data)))
>> (route/files "/" {:root "public"})
>> (route/not-found "Not Found"))
>>
>> (def app-routes-with-auth
>> (-> app-routes
>> (friend/authenticate
>> {:workflows [(openid/workflow :openid-uri "/openid" :realm "
>> http://invoize.com" :credential-fn identity)]})))
>>
>> (def app
>> (handler/site app-routes-with-auth))
>>
>>
>> Below is the stacktrace -
>>
>> java.lang.NullPointerExceptionopenid.clj:124
>> cemerick.friend.openid/workflow[fn]friend.clj:174
>> cemerick.friend/authenticate*[fn]core.clj:2432clojure.core/map[fn]
>> LazySeq.java:42clojure.lang.LazySeq.sval
>>
>> Thanks,
>> Murtaza
>>
>>
>>
>>
>> On Wednesday, December 19, 2012 7:37:04 PM UTC+5:30, Aaron Cohen wrote:
>>>
>>>
>>>
>>>
>>> On Wed, Dec 19, 2012 at 8:40 AM, Murtaza Husain <
>>> [email protected]> wrote:
>>>>
>>>> (defroutes app-routes
>>>> (GET "/" [] (resp/redirect "/landing"))
>>>> (GET "/landing" [] (resp/file-response "landing.html" {:root
>>>> "public"}))
>>>> (GET "/index" [] (index index-data))
>>>> (route/files "/" {:root "public"})
>>>> (route/not-found "Not Found"))
>>>>
>>>> (def mock-app
>>>> (-> app-routes
>>>> (friend/authenticate
>>>> {:allow-anon? false
>>>> :login-uri? "/landing"
>>>> :workflows [(openid/workflow :openid-uri "/openid" :realm "
>>>> http://invoize.com")]})))
>>>>
>>>>
>>>
>>> I'm not fully conversant with all the libraries, but don't you actually
>>> need to use mock-app somewhere?
>>>
>>>
>>>> (def app
>>>> (handler/site app-routes))
>>>>
>>>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to [email protected]
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>>
>>
>>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected] <javascript:>
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> [email protected] <javascript:>
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>
>
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en