11-21-2015 16:09
11-21-2015 16:09
May I ask how could we get the user id in OAuth 2.0? This looks like an obvious and simple question, but I find that I can not figure it out from the documentation. Thanks.
Answered! Go to the Best Answer.
11-22-2015 12:01
11-22-2015 12:01
The user id is returned in the authorization callback. It's the "user_id" value.
An example from an implicit grant callback:
http://example.com/callback#scope=nutrition+weight+location+social+heartrate+settings+sleep+activity+profile&user_id=26FWFL&token_type=Bearer&expires_in=86400&access_token=eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0NDgzMDg3MTUsInNjb3BlcyI6Indwcm8gd2xvYyB3bnV0IHdzbGUgd3NldCB3aHIgd3dlaSB3YWN0IHdzb2MiLCJzdWIiOiIyNkZXRkwiLCJhdWQiOiIyMjhZWDYiLCJpc3MiOiJGaXRiaXQiLCJ0eXAiOiJhY2Nlc3NfdG9rZW4iLCJpYXQiOjE0NDgyMjIzMTV9.pqf_QEb-Cbf6lb4JpOv-Nm0x2jcaW-w0LuLZ7RLkJfe
You can also request the user's profile, documented here. The user id is located in the response at user.encodedId .
11-22-2015 12:01
11-22-2015 12:01
The user id is returned in the authorization callback. It's the "user_id" value.
An example from an implicit grant callback:
http://example.com/callback#scope=nutrition+weight+location+social+heartrate+settings+sleep+activity+profile&user_id=26FWFL&token_type=Bearer&expires_in=86400&access_token=eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0NDgzMDg3MTUsInNjb3BlcyI6Indwcm8gd2xvYyB3bnV0IHdzbGUgd3NldCB3aHIgd3dlaSB3YWN0IHdzb2MiLCJzdWIiOiIyNkZXRkwiLCJhdWQiOiIyMjhZWDYiLCJpc3MiOiJGaXRiaXQiLCJ0eXAiOiJhY2Nlc3NfdG9rZW4iLCJpYXQiOjE0NDgyMjIzMTV9.pqf_QEb-Cbf6lb4JpOv-Nm0x2jcaW-w0LuLZ7RLkJfe
You can also request the user's profile, documented here. The user id is located in the response at user.encodedId .
12-11-2015 02:02
12-11-2015 02:02
What about Authorization Code Grant Flow, I haven't find any way to get the user_id in the docs.
12-11-2015 08:03
12-11-2015 08:03
It is in the reponse when you try to get the access token as the parameter user_id. I think Fitbit should really put this on the doc (or put a sample of each response.)
12-11-2015 14:15 - edited 12-11-2015 17:12
12-11-2015 14:15 - edited 12-11-2015 17:12
@pyus13 wrote:
What about Authorization Code Grant Flow, I haven't find any way to get the user_id in the docs.
When using the Authorization Code Grant Flow, these values are returned in the Access Token Request.
12-11-2015 18:54
12-11-2015 18:54
@jlin wrote:
It is in the reponse when you try to get the access token as the parameter user_id. I think Fitbit should really put this on the doc (or put a sample of each response.)
I've updated the documentation to include the fragment parameters returned on the callback. (Because Fitbit's OAuth 2.0 implementation conforms to the RFC and is nearly identical to other implementations, our documentation is meant to complement, not replace, the RFC.)
The example for the Authorization Code Flow, which must use the Access Token Request, already had an example response.
12-11-2015 20:10
12-11-2015 20:10
Thank you so much, I really appreciate this. Yeah, when I implement the client for Fitbit OAuth 2.0, I have also refered the RFC document, it is very useful. I think the reason I have this user id question is that it is not a standard OAuth 2.0 parameter, which there is no documentation if it is not metioned in the Fitbit doc itself.
Thanks again.