05-09-2016 20:11
05-09-2016 20:11
05-18-2016 14:13
05-18-2016 14:13
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
06-09-2019 23:52
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
06-10-2019 06:57
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).