I'm trying to make an API that use digest as authentication, When I access API via curl command line using this command, it's work
curl --digest --user website:website http://localhost/api/test/users
but when running api client using Guzzle 6 php library using this code
$handler = new GuzzleHttp\Handler\CurlHandler();
$stack = GuzzleHttp\HandlerStack::create($handler); // Wrap w/ middleware
$client = new GuzzleHttp\Client(['base_uri' => 'http://localhost', 'handler' => $stack]);
try {
$request = new GuzzleHttp\Psr7\Request('GET', $req_uri, [
'auth' => ['website', 'website', 'digest']
]);
$response = $client->send($request, ['timeout' => 2]);
} catch (Exception $e) {
echo $e->getMessage();
die();
}
return $response;
It's not working, it says
401 Unauthorized` response: {"status":false,"error":"Unauthorized"}
how to fix this? and how to implement custom handler guzzle php in the right way ?