Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error: Error code 6103, can't get domain zones #209

Open
exitcas opened this issue Apr 20, 2022 · 1 comment
Open

Fatal error: Error code 6103, can't get domain zones #209

exitcas opened this issue Apr 20, 2022 · 1 comment

Comments

@exitcas
Copy link

exitcas commented Apr 20, 2022

I have this error since some days ago, and I don't know what to do!!!

Code:

<?php
include $_ENV["ROOT"] . "vendor/autoload.php";
$key = new Cloudflare\API\Auth\APIKey($_ENV["MAIL"], $_ENV["TOKEN"]);
$adapter = new Cloudflare\API\Adapter\Guzzle($key);
//print_r($adapter);
$user = new Cloudflare\API\Endpoints\User($adapter);
$zones = new Cloudflare\API\Endpoints\Zones($adapter);
$zoneID = $zones->listZones("[domain]");
echo $zoneID;

Error:

<br />
<b>Fatal error</b>:  Uncaught GuzzleHttp\Exception\ClientException: Client error: `GET https://api.cloudflare.com/client/v4/zones?page=1&per_page=20&match=all&name=[domain]` resulted in a `400 Bad Request` response:
{"success":false,"errors":[{"code":6003,"message":"Invalid request headers","error_chain":[{"code":6103,"message":"Inval (truncated...)
 in /home/runner/[censored]/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
Stack trace:
#0 /home/runner/[censored]/vendor/guzzlehttp/guzzle/src/Middleware.php(69): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response), NULL, Array, NULL)
#1 /home/runner/[censored]/vendor/guzzlehttp/promises/src/Promise.php(204): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))
#2 /home/runner/[censored]/vendor/guzzlehttp/promises/src/Promise.php(153): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), NULL)
#3 /home/runner/[censored]/vendor/guzzlehttp/promises/src/TaskQueue.php(48): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
#4 /home/runner/[censored]/vendor/guzzlehttp/promises/src/Promise.php(248): GuzzleHttp\Promise\TaskQueue->run(true)
#5 /home/runner/[censored]/vendor/guzzlehttp/promises/src/Promise.php(224): GuzzleHttp\Promise\Promise->invokeWaitFn()
#6 /home/runner/[censored]/vendor/guzzlehttp/promises/src/Promise.php(269): GuzzleHttp\Promise\Promise->waitIfPending()
#7 /home/runner/[censored]/vendor/guzzlehttp/promises/src/Promise.php(226): GuzzleHttp\Promise\Promise->invokeWaitList()
#8 /home/runner/[censored]/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()
#9 /home/runner/[censored]/vendor/guzzlehttp/guzzle/src/Client.php(187): GuzzleHttp\Promise\Promise->wait()
#10 /home/runner/[censored]/vendor/guzzlehttp/guzzle/src/ClientTrait.php(44): GuzzleHttp\Client->request('GET', 'zones', Array)
#11 /home/runner/[censored]/vendor/cloudflare/sdk/src/Adapter/Guzzle.php(85): GuzzleHttp\Client->get('zones', Array)
#12 /home/runner/[censored]/vendor/cloudflare/sdk/src/Adapter/Guzzle.php(38): Cloudflare\API\Adapter\Guzzle->request('get', 'zones', Array, Array)
#13 /home/runner/[censored]/vendor/cloudflare/sdk/src/Endpoints/Zones.php(127): Cloudflare\API\Adapter\Guzzle->get('zones', Array)
#14 /home/runner/[censored]/web/a.php(8): Cloudflare\API\Endpoints\Zones->listZones('[domain]')
#15 {main}

Next Cloudflare\API\Adapter\ResponseException: Invalid request headers in /home/runner/acfadmin/vendor/cloudflare/sdk/src/Adapter/ResponseException.php:38
Stack trace:
#0 /home/runner/[censored]/vendor/cloudflare/sdk/src/Adapter/Guzzle.php(88): Cloudflare\API\Adapter\ResponseException::fromRequestException(Object(GuzzleHttp\Exception\ClientException))
#1 /home/runner/[censored]/vendor/cloudflare/sdk/src/Adapter/Guzzle.php(38): Cloudflare\API\Adapter\Guzzle->request('get', 'zones', Array, Array)
#2 /home/runner/[censored]/vendor/cloudflare/sdk/src/Endpoints/Zones.php(127): Cloudflare\API\Adapter\Guzzle->get('zones', Array)
#3 /home/runner/[censored]/web/a.php(8): Cloudflare\API\Endpoints\Zones->listZones('[domain]')
#4 {main}
  thrown in <b>/home/runner/[censored]/vendor/cloudflare/sdk/src/Adapter/ResponseException.php</b> on line <b>38</b><br />
@tc33
Copy link

tc33 commented Jul 9, 2022

I'm sure you've worked past this by now, but based on your parameter naming it looks like this was because you were trying to authenticate with a key, but passing a token instead. Your code would have needed to be more like this:

<?php
include $_ENV["ROOT"] . "vendor/autoload.php";
$token = new Cloudflare\API\Auth\APIToken($_ENV["MAIL"], $_ENV["TOKEN"]);
$adapter = new Cloudflare\API\Adapter\Guzzle($token);
//print_r($adapter);
$user = new Cloudflare\API\Endpoints\User($adapter);
$zones = new Cloudflare\API\Endpoints\Zones($adapter);
$zoneID = $zones->listZones("[domain]");
echo $zoneID;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants