following is the error reported by api
{"errors":[
{
"errorType": "invalid_request",
"message": "Missing 'grant_type' parameter value."
}
], "success": false}
//curl request to fetch token with use of auth code used in my code
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'https://api.fitbit.com/oauth2/token',
CURLOPT_HTTPHEADER => array(
'Authorization:Basic'.base64_encode(FITBIT_CLIENT_ID.':'.FITBIT_CLIENT_SECRET),
'Content-Type: application/x-www-form-urlencoded'
),
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => array(
'code' => $auth_code,
'client_id' => FITBIT_CLIENT_ID,
'grant_type' => "authorization_code", //auth code received in url params
'redirect_uri' => 'https://www.example.com/auth/fitbit/success'
)
));
$resp = curl_exec($curl);
curl_close($curl);
i am receiving this error. plz help to identify where could be the error.
Wrap your post field's array with to make sure you are doing the encoding (in case special characters).
CURLOPT_POSTFIELDS => http_build_query (array(
...
))
Try putting a space between Authorization header. Standard one to use Authorization: Basic
If still seeing error then use VERBOSE mode with your curl request. And update your question with that verbose output so that we can help you.