2

我已经尝试了很长时间了。我能够获取请求令牌没问题。但是,当我尝试将其交换为访问令牌时,出现以下错误:

2011-07-17 22:19:19,649 [http-8080-1] 错误 oauth.OauthService - 无法获取访问令牌!(consumerName=google, requestToken=[key:4/Azm6wQDW85iYVmeb4ogCAl70D_89, secret:Zrh9saEDJcgCo83QejOu28sU, authUrl:https://www.google.com/accounts/OAuthAuthorizeToken?oauth_token=4%2FAzm6wQDW85iYVmeb4ogCAl70D_89,is.Outh_token=4%2FAzm6wQDW85iYVmeb4ogCAl70D_89, .OAuthCommunicationException:与服务提供者通信失败:服务提供者响应错误:400(错误请求

这是控制器中的代码:

   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)

我一直在玩它,但它似乎从来没有以任何方式工作。有人有什么想法吗?

4

1 回答 1

2

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

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

于 2011-07-19T00:05:41.743 回答