07-18-2018 11:06
07-18-2018 11:06
My program opens a page using the request urls in which the user logs into. They then authorize us to use their data, and then are redirected to the callback uri (the localhost) + a code. I am able to parse this code at the end of the callback out, but I am not sure how to use it or what to do with it to get the access/refresh tokens. Any help greatly appreciated.
07-26-2018 15:14
07-26-2018 15:14
Hi @RajPatel57. I would recommend checking out the OAuth 2.0 Tutorial page to walk through the OAuth flow. This is the URL: https://dev.fitbit.com/apps/oauthinteractivetutorial. However, you can also access it from our application's settings page in the dev.fitbit.com management portal, and we will fill in all of the values for you.
After you get the code for the callback URL, you'll trade the code for the access token and refresh token. Here's an example from our documentation.
POST https://api.fitbit.com/oauth2/token
Authorization: Basic Y2xpZW50X2lkOmNsaWVudCBzZWNyZXQ=
Content-Type: application/x-www-form-urlencoded
client_id=22942C&grant_type=authorization_code&redirect_uri=http%3A%2F%2Fexample.com%2Ffitbit_auth&code=1234567890