Request::getAuthorizationHeader()
\nn\t3::Request()->getAuthorizationHeader();
Read the Authorization header from the request.
\nn\t3::Request()->getAuthorizationHeader();
Copied!
Important: If this does not work, the following line is probably missing in the .htaccess is probably missing the following line:
# nnhelpers: Use when PHP is executed in PHP CGI mode
RewriteRule . - E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
Copied!
| @return string
Source Code
public function getAuthorizationHeader()
{
$headers = null;
if (isset($_SERVER['Authorization'])) {
$headers = trim($_SERVER['Authorization']);
} else if (isset($_SERVER['HTTP_AUTHORIZATION'])) {
$headers = trim($_SERVER["HTTP_AUTHORIZATION"]);
} elseif (function_exists('apache_request_headers')) {
$requestHeaders = apache_request_headers();
foreach ($requestHeaders as $k=>$v) {
$requestHeaders[ucwords($k)] = $v;
}
if (isset($requestHeaders['Authorization'])) {
$headers = trim($requestHeaders['Authorization']);
}
}
return $headers;
}
Copied!