I'm trying to generate an ACCESS_TOKEN, then use that token to make a API call. When I try to execute the code below:
$curl = curl_init();
$ID = "5644565-564s6d5f4564-564f5sd645fd";
$SECRET = "256545fsd-456sdfs-546ds6ffds";
$AUDIANCE = "DTY";
curl_setopt_array($curl, array(
CURLOPT_URL => "https://my-url.com/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "grant_type=client_credentials&client_id=$ID&client_secret=$SECRET&audience=$AUDIANCE",
CURLOPT_HTTPHEADER => array(
"content-type: application/x-www-form-urlencoded"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
I get this message:
{
"message": "Invalid Authorization header"
}
Can someone help me?
I use Insomnia to Generate the TOKEN. you can see the Token générated from Insomnia Software. Now how can i get tis Token in my PHP script. See Insomnia Screen