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

Error using https://api.fitbit.com/oauth2/token to get token

ANSWERED

When i try to use this method to get token and refresh token to use in other methods, i get this message error:

{
"errors": [
{
"errorType": "invalid_request",
"message": "Missing parameters: code Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process."
}
],
"success": false
}
 
Can anyone help me with this question please?
Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

@JohnFitbit now, i already fixed the problem.

My problem is grant_type, i sent this in the query parameters but this camp needs to be sent in body.

Thanks for Help.

View best answer in original post

Best Answer
0 Votes
5 REPLIES 5

Hi @SamuelMira,

 

Welcome to the forums!

 

So that I may investigate, can you please provide me with your full POST request? I need to be able to see the URL endpoint, headers, and body. This should help me see how you are formatting your request and identify what may be throwing the error. Feel free to block out any sensitive information.

 

Hope to hear from you soon! Thanks!

Best Answer
0 Votes

First of all , thanks for the answer.

 

https://api.fitbit.com/oauth2/token?client_id={ClientId}&grant_type=authorization_code&redirect_uri=...}}

In the headers i give Authorization = Basic {Code base64} and Content-Type=application/x-www-form-urlencoded.

 

I sent de code directly in redirectURL because i see this in one example of this community.

Best Answer
0 Votes

@SamuelMira Are you coming across this error when trying to authorize your application or when trying to refresh your token?

 

Also, have you tried using the OAuth 2.0 Tutorial found in your application settings at dev.fitbit.com (https://dev.fitbit.com/apps/details/<Client_ID>)? It will take you through a demo of how to authorize your application, make a request, and refresh your tokens through curl.

 

If you still need assistance after going through the tutorial, please let me know and I'll be happy to assist you further.

Best Answer
0 Votes

@JohnFitbit I already followed tutorial but when i run curl on cmd i get the following error:

 

 

HTTP/1.1 401 Unauthorized
Date: Fri, 27 Sep 2019 07:55:45 GMT
Content-Type: application/json;charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Cache-Control: no-cache, private
CF-Ray: 51cbeacacbebda6e-LIS
Alt-Svc: clear
Content-Language: en-EU
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Set-Cookie: JSESSIONID=852B6528835966803CF8A6C17674A7B3.fitbit1; Path=/; Secure; HttpOnly
Set-Cookie: fct=74929ea790cb4a8fb06f589921f7073a; Path=/; Secure; HttpOnly
Vary: Origin,Accept-Encoding
Via: 1.1 google
WWW-Authenticate: Bearer realm="api.fitbit.com"
X-Frame-Options: SAMEORIGIN
Server: cloudflare

{"errors":[{"errorType":"invalid_client","message":"Invalid authorization header format. The header was not recognized to be a valid header for any of known implementations or a client_id was not specified in case of a public client Received header = null. Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process."}],"success":false}

 

Have any idea what might be causing this?

 

Best Answer
0 Votes

@JohnFitbit now, i already fixed the problem.

My problem is grant_type, i sent this in the query parameters but this camp needs to be sent in body.

Thanks for Help.

Best Answer
0 Votes