需要在Grails中设置Google Plus API的帮助吗
我正在使用GrailsOAuth插件 下面是需要在Grails中设置Google Plus API的帮助吗,grails,oauth,google-plus,Grails,Oauth,Google Plus,我正在使用GrailsOAuth插件 下面是Config.groovycode: oauth { providers { google { api = org.scribe.builder.api.GoogleApi key = 'XXX.apps.googleusercontent.com' secret = 'XXX' scope = 'https://www.googleapis.com/auth/userinfo
Config.groovy
code:
oauth {
providers {
google {
api = org.scribe.builder.api.GoogleApi
key = 'XXX.apps.googleusercontent.com'
secret = 'XXX'
scope = 'https://www.googleapis.com/auth/userinfo.profile'
callback = "${grails.serverURL}/oauth/google/callback"
successUri = "${grails.serverURL}/login/google"
}
}
}
def google() {
Token token = (Token) session[oauthService.findSessionKeyForAccessToken('google')]
def googleResource = oauthService.getGoogleResource(token,
grailsApplication.config.grails.google.api.url)
def googleResponse = JSON.parse(googleResource?.getBody())
log.info "token = ${token}"
log.info "googleResponse = ${googleResponse}"
log.info "accesstoken = ${token.token}"
log.info "id = ${googleResponse.id}"
log.info "name = ${googleResponse.name}"
//println googleResponse.name
//render params
redirect(controller: "Profile",action:"dashboard")
}
以下是LoginController
code:
oauth {
providers {
google {
api = org.scribe.builder.api.GoogleApi
key = 'XXX.apps.googleusercontent.com'
secret = 'XXX'
scope = 'https://www.googleapis.com/auth/userinfo.profile'
callback = "${grails.serverURL}/oauth/google/callback"
successUri = "${grails.serverURL}/login/google"
}
}
}
def google() {
Token token = (Token) session[oauthService.findSessionKeyForAccessToken('google')]
def googleResource = oauthService.getGoogleResource(token,
grailsApplication.config.grails.google.api.url)
def googleResponse = JSON.parse(googleResource?.getBody())
log.info "token = ${token}"
log.info "googleResponse = ${googleResponse}"
log.info "accesstoken = ${token.token}"
log.info "id = ${googleResponse.id}"
log.info "name = ${googleResponse.name}"
//println googleResponse.name
//render params
redirect(controller: "Profile",action:"dashboard")
}
这是一个错误
2015-04-22 14:10:55902[http-bio-8080-exec-8]错误
errors.GrailExceptionResolver-OAutheException在
处理请求:[GET]/uxsurvey/oauth/google/authenticate-
参数:重定向URL:响应正文不正确。无法提取
来自此的令牌和密码:'消费者未注册:
455253656547-3vrklc5phr5shur4l97qhk56ej8o028v.apps.googleusercontent.com
'.Stacktrace如下:消息:响应正文不正确。不能
从中提取令牌和机密:'消费者未注册:
455253656547-3vrklc5phr5shur4l97qhk56ej8o028v.apps.googleusercontent.com
"
这是谷歌Api客户端ID代码
Client ID
XXX.apps.googleusercontent.com
Email address
XXX.gserviceaccount.com
Client secret
XXX
Redirect URIs
http://localhost:8080/uxsurvey/login/google
Javascript Origins
none
所有的代码和配置对我来说都很好。我也在使用相同的代码,我的应用程序运行良好()。可能是您的客户ID和密码有误。可能会对您有所帮助。答案不确定,但如果这是您的实际密钥,我会在您将其发布到internet上后进行更改…;-)感谢您的建议
grailsApplication.config.grails.google.api.url
?grails.google.api.url=“”