public function getAccessToken()
{
if ($this->has('access_token')) {
return $this->get('access_token');
} elseif ($this->hasServer('X_ACCESS_TOKEN')) {
return $this->getServer('X_ACCESS_TOKEN');
} else {
$authorization = null;
if (function_exists('getallheaders')) {
$headers = getallheaders();
if (isset($headers['Authorization'])) {
$authorization = $headers['Authorization'];
}
} else {
$authorization = $this->getHeader('Authorization');
}
if ($authorization) {
$parts = explode(' ', $authorization, 2);
if ($parts[0] === 'Bearer' && count($parts) === 2) {
return $parts[1];
}
}
}
return null;
}