Я получаю токен-носитель из конечной точки API и устанавливаю следующее:
$authorization = "Bearer 080042cad6356ad5dc0a720c18b53b8e53d4c274"
Далее я хочу использовать CURL для доступа к защищенной конечной точке, но я не уверен, как и где установить токен-носитель.
Я пробовал это, но он не работает:
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json' , $authorization ));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$result = curl_exec($ch);
curl_close($ch);
return json_decode($result);
EDIT:
Согласно документации, я должен использовать токен-носитель как таковой: https://apigility.org/documentation/auth/authentication-oauth2
GET /oauth/resource HTTP/1.1
Accept: application/json
Authorization: Bearer 907c762e069589c2cd2a229cdae7b8778caa9f07