0
I’m having a hard time finalizing authentication with Juno’s api 2.0. She is asking for grant_type=client_credentials, but I’ve tried almost everything but all I got was a 400 error.
Link Doc https://dev.juno.com.br/api/v2#Operation/getAccessToken
$data = $info;
$base64 = base64_encode("$clientID:$clientSecret");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://api.juno.com.br/authorization-server/oauth/token");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$headers = [
'Content-Type: application/x-www-form-urlencoded;',
'Authorization: Basic '.$base64.'',
'Host: api.fullprog.dev',
'grant_type=client_credentials&clientId='.$clientID.'&clientSecret='.$clientSecret.''
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$server_output = curl_exec ($ch);
curl_close ($ch);
$json = json_decode($server_output);
$status = $json->status;
if ($status == '401') {
$errorMessage = $json->error;
$ErroMensagem = $json->message;
$time = date('d/m/Y H:i', strtotime($json->timestamp));
echo 'Em '.$time.' ocorreu um erro. <br>Detalhes: '.$errorMessage.' Complemento: '.$ErroMensagem;
}else{
if (isset($json->error)) {
echo $json->error.' informa: '.$json->error_description;
}else{
print $server_output ;
}
}
He returns to me: Bad Request Your browser sent a request that this server could not understand.
Or
invalid_request informa: Missing Grant type
Man, thank you so much for the answer, I was already getting lost here to learn. Thank you so much
– Iuri Moura