2

I'm developing Twitter sign in for my platform. I want to use for this purpose clj-oauth library (https://github.com/mattrepl/clj-oauth). I added [clj-oauth "1.5.2"] to my project.clj and created seperate file oauth.clj for testing purposes with only this code:

(ns greenius.service.oauth
  (:require 
    ['oauth.client :as 'oauth]))

When I try compile oauth.clj I get error:

ClassCastException clojure.lang.PersistentList cannot be cast to clojure.lang.Named  clojure.core/name (core.clj:1518)

I have an impression that I follow the guide in every bit. What could be the cause of that error?

2 Answers 2

1

Remove the ' because you are using the require from inside the ns macro, so the names have to be symbols. Example from the ns documentation:

    (ns foo.bar
  (:refer-clojure :exclude [ancestors printf])
  (:require (clojure.contrib sql combinatorics))
  (:use (my.lib this that))
  (:import (java.util Date Timer Random)
           (java.sql Connection Statement)))
Sign up to request clarification or add additional context in comments.

3 Comments

I tried to do this. If I compile this: (ns greenius.service.oauth (:require [oauth.client :as oauth])) I get FileNotFoundException Could not locate oauth/client__init.class or oauth/client.clj on classpath: clojure.lang.RT.load (RT.java:443)
Did you run lein deps after adding clj-oauth to the project file?
Yes. Strange thing, but after I rerun emacs, I get different error. Now it's: CompilerException java.lang.ClassNotFoundException: org.apache.http.conn.ssl.SSLContexts, compiling:(clj_http/conn_mgr.clj:1:1) . I tried to google it and I think the reason are conflict between libraries. I'll post here if I find solution.
1

I managed to fix the problem. First I followed th esuggestion given by @Razvanescu and changed ['oauth.client :as 'oauth] into [oauth.client :as oauth].
After that I was getting new error:
FileNotFoundException Could not locate oauth/client__init.class or oauth/client.clj on classpath: clojure.lang.RT.load (RT.java:443).
When I reran my IDE it changed into CompilerException java.lang.ClassNotFoundException: org.apache.http.conn.ssl.SSLContexts, compiling:(clj_http/conn_mgr.clj:1:1)
Googling that error led me to this: https://github.com/cemerick/friend/issues/128.
I was using friend 0.2.0 and clj-oauth uses clj-http so it applied to my problem. After I upgraded to [com.cemerick/friend "0.2.2-SNAPSHOT"] and reran my IDE the problem was gone and it works now.

Sad thing is that I realized just now that twitter grants info only about username, which in my case is practically useless for sign up...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.