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.
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
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 .
Best Answer
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
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 .
Best AnswerWhat about Authorization Code Grant Flow, I haven't find any way to get the user_id in the docs.
Best AnswerIt 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.)
Best Answer
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
@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.
Best Answer
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
@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.
Best AnswerThank 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.
Best Answer