08-11-2015 22:55 - edited 08-11-2015 22:57
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

08-11-2015 22:55 - edited 08-11-2015 22:57
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I'm getting a 404 error when clicking the allow button. I'm having this problem only in my live server(https://www.gogch.com/app/). Its working fine in my local server(http://localhost:8080) and also a test server(https://testing.gogch.com/app/).
This is what the log says
11-08-2015 10:02:14 ERROR Logger:1962 - populate com.fitbit.api.FitbitAPIException: 400: The request was invalid. An accompanying error message will explain why. {"errors":[{"errorType":"request","fieldName":"n/a","message":"This request should use https protocol."}],"success":false} at com.fitbit.api.client.http.HttpClient.httpRequest(HttpClient.java:460) at com.fitbit.api.client.http.HttpClient.get(HttpClient.java:398) at com.fitbit.api.client.FitbitApiClientAgent.httpGet(FitbitApiClientAgent.java:2784) at com.fitbit.api.client.FitbitApiClientAgent.httpGet(FitbitApiClientAgent.java:2734) at com.fitbit.api.client.FitbitApiClientAgent.getSubscriptions(FitbitApiClientAgent.java:2548) at com.fitbit.api.client.FitbitApiClientAgent.getSubscriptions(FitbitApiClientAgent.java:2537) at com.cinch.gch.controller.FitbitApiClientController.populate(FitbitApiClientController.java:1959) at com.cinch.gch.controller.FitbitApiClientController.showProfileForm2(FitbitApiClientController.java:510) at com.cinch.gch.controller.FitbitApiClientController.showCompleteAuthorizat(FitbitApiClientController.java:311) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:214) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:748) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:931) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:822) at javax.servlet.http.HttpServlet.service(HttpServlet.java:620) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:807) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745)
Live and test both use https. and its working in test. I can't figure out what is the problem in my live server. Here's the populate function where the error occurs.
public void populate(RequestContext context, HttpServletRequest request, HttpServletResponse response) { context.setApiClientService(apiClientService); context.setOurUser(getOrMakeExampleAppUser(request, response)); APIResourceCredentials resourceCredentials = context .getApiClientService().getResourceCredentialsByUser( context.getOurUser()); boolean isAuthorized = resourceCredentials != null && resourceCredentials.isAuthorized(); boolean isSubscribed = false; if (isAuthorized) { List<ApiSubscription> subscriptions = Collections.emptyList(); try { subscriptions = apiClientService.getClient().getSubscriptions( context.getOurUser()); } catch (FitbitAPIException e) { log.error("populate", e); } if (null != context.getOurUser() && subscriptions.size() > 0) { isSubscribed = true; } } request.setAttribute("actionBean", context); request.setAttribute("isSubscribed", isSubscribed); request.setAttribute("exampleBaseUrl", getExampleBaseUrl()); }
Can someone be kind enough to help me?
Regards.
Answered! Go to the Best Answer.

- Labels:
-
Java
-
OAuth 1.0a
-
Subscriptions API
Accepted Solutions
08-30-2015 06:58
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

08-30-2015 06:58
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
call backs were not correct. Thank you

08-28-2015 02:35
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

08-28-2015 02:35
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
The server is enabled in the app settings?
The callbacks are correct?
08-28-2015 10:57
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



08-28-2015 10:57
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
What is the URL that you requested that gave this error?
If you're getting an error saying that you're not using HTTPS, you're very likely not using https://api.fitbit.com somewhere.

08-30-2015 06:58
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

08-30-2015 06:58
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
call backs were not correct. Thank you

01-02-2018 10:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-02-2018 10:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Hi,
I have a similar issue. I also made a unity application and I am trying to use fitbit data with it.
I found this unity project, https://github.com/TravisEvashkevich/UnityFitbit which is amazingly helpful in understanding the whole procedure. After I ran the project thought, as expected it took me to the authorisation page, and after I clicked allow it took me to my callbackUrl. For now, I had my callbackUrl set as the one in the project or a random website of my client because I am not sure what I should set it to. Since I don't know what I am supposed to set as my callBackUrl, I don't know how to get my new returnCode/code which then remains null, so I can't use any getData functions.
Any idea what I am doing wrong?
Forgive me if my question seems foolish, I just literally started trying to work out how extracting data from fitbit works and I am stuck here the last couple of days, so I thought I should ask. xD
01-02-2018 11:28
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-02-2018 11:28
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
worked it out, never mind xD

03-14-2018 02:34
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

03-14-2018 02:34
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
How did you work it out? 🙂
I am stuck at the callback_url for the moment..
See no way out.. 🙂

10-16-2021 04:51
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

10-16-2021 04:51
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi Andion. We need to take fitbit datas on our server.Until now we couldnt do it.We are facing problems. Cn you help us or can u please show us a way to do that?Thanks for your time

