Grails中的OAuth问题

时间:2013-11-07 16:12:11

标签: grails oauth oauth-2.0

我正在使用我的grails应用程序中的twitter配置登录 当我执行run-app时获取此堆栈跟踪

Server running. Browse to http://localhost:8080/TestOAuth
Error initializing the application: Error creating bean with name 'uk.co.desirableobjects.oauth.scribe.OauthController': Initialization of bean failed;<br/>
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'oauthService': Invocation of init method failed; nested exception is uk.co.desirableobjects.oauth.scribe.exception.InvalidOauthProviderException: [:] is not a Class <br/>

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'uk.co.desirableobjects.oauth.scribe.OauthController': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'oauthService': Invocation of init method failed; nested exception is uk.co.desirableobjects.oauth.scribe.exception.InvalidOauthProviderException: [:] is not a Class
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722) <br/>

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'oauthService': Invocation of init method failed; nested exception is uk.co.desirableobjects.oauth.scribe.exception.InvalidOauthProviderException: [:] is not a Class
... 5 more <br/>
Caused by: uk.co.desirableobjects.oauth.scribe.exception.InvalidOauthProviderException: [:] is not a Class
at uk.co.desirableobjects.oauth.scribe.OauthService.afterPropertiesSet(OauthService.groovy:48)
... 5 more
| Error Forked Grails VM exited with error

这是我为twitter配置的

oauth {
    providers {
        twitter {
            api = 'TwitterApi'
            key = 'i have my key here'
            secret = 'i have my secrete key here'
            successUri = '/success.gsp'
            failureUri = '/fail.gsp'
        }
    }
    debug = true
}

1 个答案:

答案 0 :(得分:3)

提供者API是一个类(来自scribe API),而不是String,必须在配置中引用。

import org.scribe.builder.api.TwitterApi

oauth {
    providers {
        twitter {
            api = TwitterApi
            key = 'i have my key here'
            secret = 'i have my secrete key here'
            successUri = '/success.gsp'
            failureUri = '/fail.gsp'
        }
    }
    debug = true
}