Skip to content

Commit

Permalink
Cloudflare issue 3148588: Fix headers if token is used.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lio Novelli committed Jan 11, 2021
1 parent 48b6f55 commit c440ef5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/ApiEndpoints/CloudFlareAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,18 @@ abstract class CloudFlareAPI {
*/
public function __construct($apikey, $email, MockHandler $mock_handler = NULL) {
$this->apikey = $apikey;

$this->email = $email;
$headers = [
'X-Auth-Key' => $apikey,
'X-Auth-Email' => $email,
'Content-Type' => 'application/json',
];
if (strlen($apikey) === self::API_KEY_LENGTH) {
$headers['Authorization'] = 'Bearer ' . $apikey;
}
else {
$headers['X-Auth-Key'] = $apikey;
$headers['X-Auth-Email'] = $email;
}

$client_params = [
'base_uri' => self::API_ENDPOINT_BASE,
Expand Down

0 comments on commit c440ef5

Please sign in to comment.