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

Generating subscription Id

ANSWERED

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";
}

 

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

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

Ivan Bahdanau
Senior Software Developer at Fitbit

View best answer in original post

Best Answer
0 Votes
1 REPLY 1

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

Ivan Bahdanau
Senior Software Developer at Fitbit
Best Answer
0 Votes