diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index 3e0d7549f7f..f01a6d56538 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -120,7 +120,7 @@ class DolibarrApiAccess implements iAuthenticate if (isset($_SERVER['HTTP_DOLAPIKEY'])) { // HTTP Header entry "DOLAPIKEY: ..." can be read with $_SERVER["HTTP_DOLAPIKEY"] $api_key = $_SERVER['HTTP_DOLAPIKEY']; // With header method (recommended) - } else { + } elseif (empty($api_key)) { $headers = getallheaders(); // HTTP Header entry "Authorization: Bearer ..." can be read with getallheaders $api_key = preg_replace('/^Bearer\s+/i', '', empty($headers['Authorization']) ? '' : $headers['Authorization']); };