我正在OAuth
为Fitbit
. 我已经完成了所有的过程。请参考屏幕截图。
为此,我的控制器上有代码,例如
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 页面会像这样打开。
在通过所有凭证后,我发现了一个错误——