1

我很想在我的 grails 应用程序中使用 twitter 配置登录,当我运行应用程序时获取此堆栈跟踪

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
}
4

1 回答 1

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
}
于 2013-11-07T16:29:02.033 回答