05-09-2016 20:11
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-09-2016 20:11
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I am new to fitbit, I have integrated fitbit with my application, first time I authenticate user it works fine, I got a token and using that token I can access user activity data.
If I call Refresh token before 1 hour, I am able to get a new refreshed token, however if I request activity data using this renewed token I received an error.
And after 1 hr if I try to call Refresh token it gives me error and not return Refreshed token.
Do any one have some sample code for .net c# app that works with Refresh token to get activities data. So that I can figure it out what I did wrong.
Thanks in advance.
Akhilesh
05-18-2016 14:13
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-18-2016 14:13
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hello -
After authentication, you end up with an access token. I see you know this, because you are able to query data. When you receive that access token, you are also given a refresh token ... I think you know this, I'm not sure ... but you do receive a refresh token too, and you need to store this refresh token along with your access token.
After an hour, your access token is no longer any good and you need to get a new one using your refresh token. You use the refresh token to get both a new access token AND a new refresh token in a refresh request-- when you use your refresh token to get an access token it becomes no good after two minutes, so be sure to store both the new access token and refresh token you receive from your single refresh request.
I feel possibly your not aware that you get back two tokens when you request a refresh. They are stored in JSON values access_token and response_token in the JSON reponse to the refresh request.
Hope this helps.
Jay

06-09-2019 23:52
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

06-09-2019 23:52
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi can you tell me how should i store fitbit api access_token object in mysql table using php. Because if i store access_token and refresh token in seperate columns and while using refresh token to generate new access_token it giving a error that hasExpired() function called on string.

06-10-2019 06:57
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

06-10-2019 06:57
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
We store both the access token and refresh token in their own columns and as variable length strings. We use PostgreSQL and the commands to create these columns are:
ALTER TABLE core.fitbit_auth ADD COLUMN access_token CHARACTER VARYING(400);
ALTER TABLE core.fitbit_auth ADD COLUMN refresh_token CHARACTER VARYING(400);
After making a refresh request, make sure you're storing both the new access (for requesting data) and new refresh token (for the next refresh period).

