Guzzle: No method to handle authorization key?

199 views
Skip to first unread message

knoxsecs...@gmail.com

unread,
Aug 12, 2016, 8:52:59 PM8/12/16
to Guzzle - PHP HTTP client and REST client framework
Hi,

I am trying to replicate a curl request in basic format
ie
Login to remote device with the followiung:

==>http://user:pa...@123.456.789.123:8080/SomeQueryHere

Usually returns a 200 or some xml for example, definately works

I have installed guzzle and am trying to make send out the same thing, and then print the response


First query :


$client = new Client();
$request = $client->get('http://123.456.789.123:8080/SomeQuery');
$request->setAuth('User', 'Pass');
$response = $request->send();

Returns:

Message: Client error response [url] http://123.456.789/System/SomeQuery [status code] 401 [reason phrase] Unauthorized


So its getting there, thought I might try a different structure

$client = new Client();
$credentials = base64_encode('user:pass');
$response = $client->get('123.456.789.123:8080/SomeQueryHere', [
    'Authorization' => ['Basic '.$credentials] ]);

Returns:

Type: InvalidArgumentException Message: No method is configured to handle the Authorization config key


I am stuck at the moment and would like to know how why it is unathorized when the credentials are correct and why the second query doesnt work at all?


Can anyone suggest how I can get the queries working please?


Thanks!

Reply all
Reply to author
Forward
0 new messages