05-22-2016 19:16
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-22-2016 19:16
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hello:
I have managed to integrate with fitbit and get my own data from a Java-based server. Now I require to obtain data from other people, who give me permission. When attempting to obtain such data, an error is generated, apparently because the client does not match secret.
Should I register the same application data for each user which I'll get data ?. How should I request data from more than one person?
05-23-2016 04:05
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

SunsetRunner
05-23-2016 04:05
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
each user account has its own secret.
and that's good, else anybody would be able to get user's data.

05-30-2016 17:08
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-30-2016 17:08
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
hello:
But, i need register the same application with each user?

05-31-2016 11:25
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



05-31-2016 11:25
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
No, a single application can retrieve multiple people's data. Each person must authorize your application. This authorization results in an access token. Your application will need to use each person's access token to retrieve their data.

06-26-2016 15:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

06-26-2016 15:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Hello,
I have not been able to make it work for more than one user. The api client invokes the authorization service with the following URL:
https://www.fitbit.com/oauth2/authorize?scope=activity+nutrition+heartrate+location+profile+settings...
The client_id is the registered application. This is what I do:
1. Generate a request by an Apache API as follows:
OAuthClientRequest request = OAuthClientRequest
.authorizationLocation(oauthDetails.getAuthenticationServerUrl())
.setClientId(oauthDetails.getClientId())
.setResponseType(OAuthConstants.CODE)
.setScope(oauthDetails.getScope())
.setState(OAuthConstants.STATE)
.buildQueryMessage();
2. Include the header as follows:
servletResponse.setHeader(OAuthConstants.AUTHORIZATION,
OAuthConstants.BASIC + " " +
Base64Encoded.encodeCredentials(oauthDetails.getClientId(),
oauthDetails.getClientSecret()));
3. Redirect to the URL:
servletResponse.sendRedirect(request.getLocationUri());
4. When the fitbit server redirects to my application, I receive the petition and request an authorization code:
OAuthAuthzResponse oar = OAuthAuthzResponse.oauthCodeAuthzResponse(servletRequest);
String code = oar.getCode();
5. With this authorization code, I request the token.
--------
HttpClient client = HttpClientBuilder.create().build();
HttpPost post = new HttpPost(oauthDetails.getTokenEndpointUrl());
post.addHeader(OAuthConstants.AUTHORIZATION, OAuthConstants.BASIC+" " +
Base64Encoded.encodeCredentials(oauthDetails.getClientId(),
oauthDetails.getClientSecret()));
List<BasicNameValuePair> parametersBody = new ArrayList<BasicNameValuePair>();
parametersBody.add(new BasicNameValuePair(OAuthConstants.CLIENT_ID, oauthDetails.getClientId()));
/*El parámetro authorization_code, es obligatorio para que se produzca la conectividad con el sistema */
parametersBody.add(new BasicNameValuePair(OAuthConstants.GRANT_TYPE, OAuthConstants.GRANT_TYPE_AUTHORIZATION_CODE));
parametersBody.add(new BasicNameValuePair(OAuthConstants.REDIRECT_URI,oauthDetails.getRedirectURI()));
parametersBody.add(new BasicNameValuePair(OAuthConstants.SCOPE, oauthDetails.getScope()));
parametersBody.add(new BasicNameValuePair(OAuthConstants.CODE, code));
post.setEntity(new UrlEncodedFormEntity(parametersBody, HTTP.UTF_8));
post.setConfig(requestConfig);
HttpResponse respuesta = client.execute(post);
int statusCode = respuesta.getStatusLine().getStatusCode();
System.out.println("statusCode=" + statusCode);
String location = getHeader(respuesta.getAllHeaders(), OAuthConstants.LOCATION_HEADER);
System.out.println("location: " + location);
System.out.print("statusCode=" + statusCode);
/*Recupera el token de acceso*/
Map<String, String> map = handleResponse(respuesta);
access_token = map.get(co.edu.javeriana.misyc.smrpn.fitbit3.OAuthConstants.ACCESS_TOKEN);
// long expires_in = Long.parseLong(map.get(co.edu.javeriana.misyc.smrpn.fitbit3.OAuthConstants.EXPIRES_IN));
String refresh_token = map.get(co.edu.javeriana.misyc.smrpn.fitbit3.OAuthConstants.REFRESH_TOKEN);
String scope = map.get(co.edu.javeriana.misyc.smrpn.fitbit3.OAuthConstants.SCOPE);
String token_type = map.get(co.edu.javeriana.misyc.smrpn.fitbit3.OAuthConstants.TOKEN_TYPE);
String user_id = map.get(co.edu.javeriana.misyc.smrpn.fitbit3.OAuthConstants.USER_ID);
--------
The problem is that the system returns me a token for the last user logged into the system, and I do not know how to make me return a token for a particular user..
6. Finally, with the token, I request server resources:
https://api.fitbit.com/1/user/-/activities/date/2016-06-24.json
or
https://api.fitbit.com/1/user/######/activities/date/2016-06-24.json
Your help please. How to get a token for each user?
08-07-2018 10:59
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

08-07-2018 10:59
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hello there,
I'm trying to develop a java based application for fetching my own data. Will you be able to assist me? Since you have already developed a Java-based application to grab your own data.
Regards,
Ananth

10-24-2018 22:13
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

10-24-2018 22:13
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
can you please elaborate?
how can you do that? where do you put the access token from the other users?
can you you please be more specific?
https://dev.fitbit.com/apps/new
there is not place to put other users...do you mean the subcribers? parts
thank you

