I Successfully Implemented the authorization step and i got the code value with redirect_uri. and while Implementing FitBit OAuth AccessToken Request (https://wiki.fitbit.com/display/API/OAuth+2.0) i am getting the following error:
WARN : org.apache.http.impl.client.DefaultHttpClient - Authentication error: Unable to respond to any of these challenges: {oauth=WWW-Authenticate: OAuth realm="https%3A%2F%2Fapi008-g4.prod.dal05.fitbit.com"} {"errors":[{"errorType":"oauth","fieldName":"n/a","message":"invalid_request, Missing grant_type parameter value"}],"success":false}
as per document i supplied every recommended values and the code is like:
String authString = fitbit.getClient_id()+":"+fitbit.getClient_secret(); String authEncString = Base64.getEncoder().encodeToString(authString.getBytes()); String url3 = fitbit.getAccesstoken_uri(); HttpClient httpClient = new DefaultHttpClient(); HttpGet request = new HttpGet(url3); request.addHeader("Authorization", "Basic " + authEncString); request.addHeader("Content-Type","application/x-www-form-urlencoded"); request.addHeader("code", code); request.addHeader("grant_type",fitbit.getGrant_type()); request.addHeader("client_id", fitbit.getClient_id()); request.addHeader("redirect_uri", fitbit.getRedirect_url()); HttpResponse response = httpClient.execute(request); String json = EntityUtils.toString(response.getEntity(), "UTF-8");
Here, grant_type value is authorization_code
Accesstoken_uri : https://api.fitbit.com/oauth2/token
Can any one solve this?