2011-07-17 52 views
2

我已经尝试了很长一段时间了。我能够获取请求令牌没有问题。但是,当我试图换取访问令牌我收到以下错误:如何使用Grails oauth插件获取访问令牌?

2011-07-17 22:19:19,649 [http-8080-1] ERROR oauth.OauthService - Unable to fetch access token! (consumerName=google, requestToken=[key:4/Azm6wQDW85iYVmeb4ogCAl70D_89, secret:Zrh9saEDJcgCo83QejOu28sU, authUrl:https://www.google.com/accounts/OAuthAuthorizeToken?oauth_token=4%2FAzm6wQDW85iYVmeb4ogCAl70D_89, isOAuth10a:true]) oauth.signpost.exception.OAuthCommunicationException: Communication with the service provider failed: Service provider responded in error: 400 (Bad Request

这里是在控制器代码:

def OauthService 
if (session.oauthToken == null) { 
     flash.message = "The token could no be retrieved... Please try again" 
     redirect(uri:"/") 
    } 
    def requestToken = OauthService.fetchRequestToken('google') 
    def accessToken = OauthService.fetchAccessToken('google', requestToken) 

我一直在玩有关使用它,但它似乎从来没有以任何方式工作,我做到了。有没有人有任何想法?

回答

2

如果你看看OAuth plugin docs,它提到一些Google API需要在OAuth配置(Config.groovy)中设置scope属性。考虑到Google服务器返回400 Bad Request,可能值得仔细检查。

此外,启用grails.app.service.org.grails.plugins.oauthgrails.app.controller.org.grails.plugins.oauth程序包的调试日志记录可能会提供更多线索。

相关问题