I am integrating amadeus flight search api and getting error while using access_token. I guess problem is at retrieving the access token?
{ "errors": [ { "code": "38191", "title": "Invalid HTTP header", "detail": "Missing or invalid format for mandatory Authorization header", "status": "401" } ] }
I need to get all the flights from source to destination with price details.
$curls = curl_init();
curl_setopt($curls, CURLOPT_URL, 'https://test.api.amadeus.com/v1/security/oauth2/token');
curl_setopt($curls, CURLOPT_POST, true);
curl_setopt($curls, CURLOPT_POSTFIELDS, "grant_type=client_credentials&client_id=$secretid&client_secret=$secretkey");
curl_setopt($curls, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
$token = curl_exec($curls);
$data = json_decode($token,true);
curl_setopt($curls, CURLOPT_URL, 'https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=SYD&destinationLocationCode=BKK&departureDate=2020-10-01&returnDate=2020-08-05&adults=2&includedAirlineCodes=TG&max=3');
curl_setopt($curls, CURLOPT_HTTPHEADER, array('Authorization: Bearer' .$data['access_token']));
$result = curl_exec($curls);
if (curl_errno($curls)) {
echo 'Error:' . curl_error($curls);
}
//print_r ($result);
curl_close ($curls);
Missing or invalid format for mandatory Authorization headerLook at the documentation to find out what you missed - RiggsFolly