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

400 Bad Request trying simple test script. #142

Closed
stussey opened this issue Jul 12, 2020 · 1 comment
Closed

400 Bad Request trying simple test script. #142

stussey opened this issue Jul 12, 2020 · 1 comment

Comments

@stussey
Copy link

stussey commented Jul 12, 2020

Hi folks, I'm just getting started using your sdk. I attempted to write a small test script based on simple example. When I attempt to run it I get back a lot of error messages of which I have pasted below.

Error received:

PHP Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: GET https://api.cloudflare.com/client/v4/user 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/dev/repos/cwpdev/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113

Stack trace:
#0 /home/dev/repos/cwpdev/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create()
#1 /home/dev/repos/cwpdev/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp{closure}()
#2 /home/dev/repos/cwpdev/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler()
#3 /home/dev/repos/cwpdev/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise{closure}()
#4 /home/dev/repos/cwpdev/vendor/guzzlehttp/promises/src/Promise.php(246): GuzzleHttp\Promise\TaskQueue->run()
#5 /home/dev/repos/cwpdev/ in /home/dev/repos/cwpdev/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 113

This is my code:
`<?php

require_once('vendor/autoload.php');

$key = new \Cloudflare\API\Auth\APIKey('xxxxx@xxxxx.com', 'xxxxx');
$adapter = new Cloudflare\API\Adapter\Guzzle($key);
$user = new \Cloudflare\API\Endpoints\User($adapter);

echo 'Your user ID is: ' . $user->getUserID() . PHP_EOL;
`
I have verified that I am using the correct email address and Api key for my account.
Any direction would be most appreciated.

@stussey stussey changed the title 400 Bad Request trying simple testscript. 400 Bad Request trying simple test script. Jul 12, 2020
@stussey
Copy link
Author

stussey commented Jul 12, 2020

This turned out to be a revoked API key.

@stussey stussey closed this as completed Jul 12, 2020
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

1 participant