How to import Fitbit data into WordPress Part 2: First request with Postman

March 23, 2021

In Part 1 you got four critical pieces of data: Client ID, Client Secret, a temporary authorization code and a Base64 Authorization header. Now we switch to Postman to access the Fitbit API. Postman is an application that you can download for free. It’s great way to test APIs and it can generate code we’ll use later. The goal of this part is to use the temporary authorization code and the Base64 Authorization header to make an HTTP request to get an access token and a refresh token

Fire up Postman and start a new POST request. You’ll need the following bits of information:

Parameters
KEY
codetemporary authorization code from Step 1
grant_typeauthorization_code
redirect_uriURL from registration in Step 1, must match exactly
Headers
AuthorizationBasic Base64 Authorization from Step 1 (that is, the word Basic then a space then the Base64 code)
Content-Typeapplication/x-www-form-urlencoded

Like so:

After clicking “Send”, you should get results like those shown below.

Take note of the “access_token” and the “refresh_token”. Using the access token you can retrieve data from the Fitbit API, but it expires in 8 hours. Luckily you can use the refresh token to get a new access code (and a new refresh token) whenever you like. We’ll get into this in Part 3.