Get Guzzle to make HTTP POST request with Digest Auth

Viewed 1695

I'm having trouble getting Guzzle to work with a request using Digest Auth. The details for the private API we're connecting to are right and work using our legacy cURL code as well as from API testing apps, but I can't get it working using Guzzle.

$client = new Guzzle\Http\Client("http://api.example.com");
$client->post("posts", null, ["title" => "Post title"])
    ->setAuth("username", "password", "Digest")
    ->send();

I've also tried wrapping the password in md5().

...
->setAuth("username", md5("password"), "Digest")
...

As well as attempting auth through the headers.

...
$client->post("posts", [
    "request.options" => [
        "auth" => ["username", "password", "Digest"]
    ]
], ["title" => "Post title"])
...

Am I missing something silly? I've looked through all sorts of documentation and examples but can't seem to get this authorization working.

0 Answers
Related