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

Step 4 exchange auth code for access and refresh token

I keep receiving an error with my fit bit request specified in step 4 of the authorization guide. 

I get userCode from the call back url. 

const sendJson = {
                "method": "POST",
                headers: {
                    Authorization: 'Basic MjNCSFM4OmM0ZTI2Mjg0MjIzOWQwNWQzZjljNzU2ZGExZDAzZmUw',
                    'Content-Type': "application/x-www-form-urlencoded"
                }
            };
            var requestUrl = `https://api.fitbit.com/oauth2/token?clientId=23BHS8&code=${userCode}&grant_type=authorization_code`;
     

            fetch(requestUrl, sendJson)
                .then(response => response.json())
                .then(data => console.log(data));
 
 
In postman my error returned is 
    "errors": [
        {
            "errorType""invalid_grant",
            "message""Authorization code invalid: cff86e02c5c4c9f5bdbf3253c1c675661f3b16d4 Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process."
        }
    ],
    "success"false
}
 
Not sure why i am getting this error. 
Best Answer
0 Votes
0 REPLIES 0