2011-07-17 50 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程序包的調試日誌記錄可能會提供更多線索。

相關問題