08-30-2015 08:52 - edited 08-30-2015 08:54
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

08-30-2015 08:52 - edited 08-30-2015 08:54
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
We're migrating from OAuth1 to OAuth2 and I want to use the same subcription Id as before. OAuth1 was implemented by another developer who used Fibit4J library. Now with AOuth2, I want to generate the same SubscriptionId as before for a user ID
this is the pice of code
context.getOurUser().getUserId();
that generates the subscription Id (eg. it generates an id '806055743' for user ID '2WWZHP'). Someone please tell me how does fitbit4J generate this subscription Id. Is it possible for me to generate the same id without using Fibit4j so I can continue using the same subscription Id without unsubscribing all the subscription id's for far
public String showSubscribe(HttpServletRequest request, HttpServletResponse response) { RequestContext context = new RequestContext(); populate(context, request, response); if (!isAuthorized(context, request)) { showAuthorize(request, response); } try { context.getApiClientService().subscribe(fitbitSubscriberId, context.getOurUser(), APICollectionType.activities, getActivitiesSubscriptionId(context)); // log.debug(); populate(context, request, response); } catch (FitbitAPIException e) { request.setAttribute("errors", Collections.singletonList(e.getMessage())); e.printStackTrace(); } try { request.setAttribute("subscriptions", apiClientService.getClient() .getSubscriptions(context.getOurUser())); } catch (FitbitAPIException e) { log.error("showSubscribe", e); } return "subscriptions"; } private String getActivitiesSubscriptionId(RequestContext context) { return context.getOurUser().getUserId() + ":0"; }
Answered! Go to the Best Answer.

- Labels:
-
Java
-
OAuth 1.0a
-
OAuth 2.0
Accepted Solutions
08-31-2015 13:57 - edited 08-31-2015 13:57
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


08-31-2015 13:57 - edited 08-31-2015 13:57
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Fitbit does not generates subscriptions ids.
The subscription id is passed with request when you create subscription:
POST https://api.fitbit.com/1/user/-/apiSubscriptions/{here_where_you_specify_id_you_want}.json
You can get list of all subscriptions with ids by calling:
GET https://api.fitbit.com/1/user/-/apiSubscriptions.json
Senior Software Developer at Fitbit

08-31-2015 13:57 - edited 08-31-2015 13:57
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


08-31-2015 13:57 - edited 08-31-2015 13:57
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Fitbit does not generates subscriptions ids.
The subscription id is passed with request when you create subscription:
POST https://api.fitbit.com/1/user/-/apiSubscriptions/{here_where_you_specify_id_you_want}.json
You can get list of all subscriptions with ids by calling:
GET https://api.fitbit.com/1/user/-/apiSubscriptions.json
Senior Software Developer at Fitbit

