Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to refresh access token with refresh token (Python)?

Hey guys, 

not really sure how to get the new access token using a refresh token. What command/process do I use? 

 

Best Answer
0 Votes
1 REPLY 1

Hi @ericmarnadi,

 

Here's the link to the documentation on using the refresh token to obtain a new access/refresh token pair: https://dev.fitbit.com/build/reference/web-api/oauth2/#refreshing-tokens. 

 

Basically, you'll follow similar process for obtaining the access token by executing 

 

POST https://api.fitbit.com/oauth2/token

but, instead you'll specifying the grant_type = refresh_token, your refresh token and the expiration time.  Here's an example of what that would look like

 

POST https://api.fitbit.com/oauth2/token
Authorization: Basic Y2xpZW50X2lkOmNsaWVudCBzZWNyZXQ=
Content-Type: application/x-www-form-urlencoded

grant_type=refresh_token&refresh_token=abcdef01234567890abcdef01234567890abcdef01234567890abcdef0123456

In this example, we didn't specify the expiration time. Therefore, the default expiration time of 28800 seconds or 8 hours will be used.

 

Gordon

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes