使用clj-oauth的问题

时间:2015-08-31 17:10:21

标签: oauth clojure

我正在为我的平台开发Twitter登录。我想为此目的使用clj-oauth库(https://github.com/mattrepl/clj-oauth)。我将[clj-oauth "1.5.2"]添加到project.clj并创建了单独的文件oauth.clj,仅用于此代码进行测试:

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

当我尝试编译oauth.clj时,我收到错误:

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

我的印象是我每次都遵循指南。可能是造成这种错误的原因是什么?

2 个答案:

答案 0 :(得分:1)

删除'因为您在ns宏中使用require,所以名称必须是符号。 ns文档中的示例:

    (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)))

答案 1 :(得分:1)

我设法解决了这个问题。 首先我跟随@Razvanescu给出的提示并将['oauth.client :as 'oauth]更改为[oauth.client :as oauth]
之后我收到了新的错误:
FileNotFoundException Could not locate oauth/client__init.class or oauth/client.clj on classpath: clojure.lang.RT.load (RT.java:443)
当我重新启动IDE时,它变为CompilerException java.lang.ClassNotFoundException: org.apache.http.conn.ssl.SSLContexts, compiling:(clj_http/conn_mgr.clj:1:1)
谷歌搜索该错误导致我:https://github.com/cemerick/friend/issues/128 我正在使用朋友0.2.0而clj-oauth使用clj-http因此它适用于我的问题。在我升级到[com.cemerick/friend "0.2.2-SNAPSHOT"]并重新启动我的IDE后,问题就消失了,现在就可以了。

令人遗憾的是,我刚才意识到Twitter只授予用户名信息,这在我的情况下几乎没有用于注册......