diff --git a/application/controllers/api/v1/API_V1_Controller.php b/application/controllers/api/v1/API_V1_Controller.php index 103c0f81..4e264efb 100644 --- a/application/controllers/api/v1/API_V1_Controller.php +++ b/application/controllers/api/v1/API_V1_Controller.php @@ -75,7 +75,9 @@ class API_V1_Controller extends CI_Controller { protected function _getBearerToken() { $headers = $this->_getAuthorizationHeader(); + // HEADER: Get the access token from the header + if ( ! empty($headers)) { if (preg_match('/Bearer\s(\S+)/', $headers, $matches)) @@ -109,15 +111,18 @@ class API_V1_Controller extends CI_Controller { elseif (function_exists('apache_request_headers')) { $requestHeaders = apache_request_headers(); - // Server-side fix for bug in old Android versions (a nice side-effect of this fix means we don't care about capitalization for Authorization) + + // Server-side fix for bug in old Android versions (a nice side-effect of this fix means we don't care + // about capitalization for Authorization). $requestHeaders = array_combine(array_map('ucwords', array_keys($requestHeaders)), array_values($requestHeaders)); - //print_r($requestHeaders); + if (isset($requestHeaders['Authorization'])) { $headers = trim($requestHeaders['Authorization']); } } } + return $headers; }