1

我正在OAuthFitbit. 我已经完成了所有的过程。请参考屏幕截图。

为此,我的控制器上有代码,例如

class MyController {

    def myService;

    static defaultAction = "getUserDetails"
    String subscriber_id = "1";

    def getUserDetails() {
        if (request.getParameter("completeAuthorization") != null) {
            forward(action: 'showUserInfo')
        }
        else {
            try {

                response.sendRedirect(FitBitAPI.getBean().getResourceOwnerAuthorizationURL(new LocalUserDetail("-"), grailsApplication.config.myBaseUrl + "/my/showUserInfo?completeAuthorization="));
            }
            catch (FitbitAPIException e) {
                throw new ServletException("Exception during performing authorization", e);
            }

        }
    }

    def showUserInfo() {
        /*println "${params}--------------------------------"*/
        render {params}


        APIResourceCredentials resourceCredentials = myService.getCredentials(params)
        UserInfo userInfo;
        println "=====================gggggg================================================>>>>"+resourceCredentials
        try {
            userInfo = FitBitAPI.getBean()?.getClient()?.getUserInfo(new LocalUserDetail(resourceCredentials.getLocalUserId()));
            println "===================after FitBitAPI==============================================="
            [userInfo: userInfo]
            println "===================user Info====================================================="

        } catch (FitbitAPIException e) {
            throw new ServletException("Exception during getting user info", e);
        }
        [params:params]
    }
}

起初,我在我的索引页面上创建了一个链接,并在点击getUserDetails()调用时像 ----- 在此处输入图像描述

当我单击此链接 Fitbit 时,OAuth 页面会像这样打开。 在此处输入图像描述

在通过所有凭证后,我发现了一个错误—— 在此处输入图像描述

4

2 回答 2

0

我使用fitbit4j,问题就解决了。

于 2015-04-11T17:21:40.937 回答
0

'fitbit4j'现在已弃用,但您可以将scribe-java用于 OAuth 1.0。

于 2015-05-14T09:00:02.773 回答