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

Refresh access tokens missing grant_type

ANSWERED

Hello!

 

I'm trying to refresh my access tokens, but I'm having some issues.

I've used the refresh token documentation from here.

 

I'll explain a bit how I'm trying to retrieve the new access tokens.

 

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

Headers: Content-Type: application/json

Authorization: Basic and a Base64 encoded string containing app_id:app_secret

 

In the body of the post I have:

{ "grant_type":"refresh_token", "refresh_token":"x" }

After posting I get the error:

{
    "errors": [
        {
            "errorType": "invalid_request",
            "message": "Missing 'grant_type' parameter value. Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process."
        }
    ],
    "success": false
}

What am I missing here? Thanks! 

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

This is quite awkward, but I have two Fitbit applications registered and I was using the wrong credentials..

View best answer in original post

Best Answer
0 Votes
2 REPLIES 2

Oke, so finally I got it to work. The problem was that I was sending JSON in the body and not application/x-www-form-urlencoded formatted. But now a new problem occurred:

{"errors":[{"errorType":"invalid_grant","message":"Refresh token invalid: 1234567890. Visit https://dev.fitbit.com/docs/oauth2 for more information"}]}

I'm 100% sure that the refresh token is correct, because I revoked all the tokens and went through a new authorization code grant flow to get a new token. Also the headers are correct:

refresh_headers = ["Authorization": "Basic #{Base.encode64("client_id:client_secret")}", "Content-Type": "application/x-www-form-urlencoded"]

What could be the issue here?

Best Answer
0 Votes

This is quite awkward, but I have two Fitbit applications registered and I was using the wrong credentials..

Best Answer
0 Votes