Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Response code 400 while firing an api after retrieving access token

Hi, 

 

Please  anyone could see this through this problem. Solution would be grateful.

 

I have used Apache Oltu library for this (Grails platform).

 

I have generated the Acess Token and attached to the parameters and while fetching the data from the Fit Api, it send the responseCode error 400.

https://api.fitbit.com/1/user/XXX/activities/date/2016-06-07/2016-07-30.json(Get Request)

 

Code snippet:

 

 OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());
OAuthClientRequest bearerClientRequest= new OAuthBearerClientRequest(fitbitbaseUrl).setAccessToken(oAuthResponse.getAccessToken()).buildQueryMessage()
bearerClientRequest.setHeader("Authorization","Bearer $oAuthResponse.accessToken")
OAuthResourceResponse resourceResponse = oAuthClient.resource(bearerClientRequest, OAuth.HttpMethod.GET, OAuthResourceResponse.class);
println("\nresourceResponse properties===="+resourceResponse.properties)

I couldn't get further than this.It simply prints this logs indicated below

[headers:[Fitbit-Rate-Limit-Limit:[150], Transfer-Encoding:[chunked], null:[HTTP/1.1 400 Bad Request], CF-RAY:[2d7f43857d1706d6-LHR], Server:[cloudflare-nginx], Connection:[keep-alive], Date:[Thu, 25 Aug 2016 13:06:52 GMT], X-Frame-Options:[SAMEORIGIN], Fitbit-Rate-Limit-Remaining:[149], Vary:[Accept-Encoding], Content-Language:[en], Fitbit-Rate-Limit-Reset:[3188], Cache-control:[no-cache, private], Content-Type:[application/json;charset=UTF-8]], class:class org.apache.oltu.oauth2.client.response.OAuthResourceResponse, contentType:application/json;charset=UTF-8, bodyAsInputStream:sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@62a0d30, responseCode:400]

Thanks,

 

Best Answer
0 Votes
0 REPLIES 0