This is the error am getting in my curl PHP
HTTP/1.1 401 Unauthorized Cache-Control: no-cache Pragma: no-cache Content-Type: application/json; charset=utf-8 Expires: -1 Server: Microsoft-IIS/10.0 X-AspNet-Version: 4.0.30319 WWW-Authenticate: Bearer WWW-Authenticate: Bearer X-Powered-By: ASP.NET Date: Thu, 23 Apr 2020 10:57:54 GMT Content-Length: 61 {"Message":"Authorization has been denied for this request."}";
The API isn't receiving an access token, I think its lacking authorization. pls help me with this below authorization code to add in my code properly, am a little bit confused where to add it.
below is the authorisation code
curl_setopt($handle1, CURLOPT_HTTPHEADER, array("Authorization: Bearer ".$access_token)); //the code I have written
<?php $access_token = $_SESSION['token']; $request_headers = array(); $request_headers[] = 'Bearer: ' . $access_token; //$request_headers[]='Content-Length:150'; $handle1 = curl_init(); $api_url = 'API'; curl_setopt_array( $handle1, array( CURLOPT_URL => $api_url, CURLOPT_POST => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => $request_headers, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_HEADER => true, CURLOPT_TIMEOUT => -1, ) ); $data = curl_exec($handle1); echo serialize($data); ?>