vytautasgimbutas/lib-hawk-authentication-guzzle-subscriber

Guzzle subscriber for Hawk Authentication

v1.0.1 2015-03-15 08:31 UTC

This package is not auto-updated.

Last update: 2024-12-17 04:04:00 UTC


README

Hawk specification can be found here: http://alexbilbie.com/2012/11/hawk-a-new-http-authentication-scheme/

Using Symfony2? Check out Hawk Authentication bundle that uses Symfony2 Security component.

Usage

use Tornado\Component\HawkAuthentication\HawkAuthenticationSubscriber;
use Dflydev\Hawk\Client\ClientBuilder;
use Dflydev\Hawk\Credentials\Credentials;
use GuzzleHttp\Client;

$id = '12345';
$secret = 'asd';

$client = ClientBuilder::create()->build();
$credentials = new Credentials($secret, 'sha256', $id);

$hawkAuthenticationPlugin = new HawkAuthenticationSubscriber(
    $client,
    $credentials
);

$httpClient = new Client();
/** @var \GuzzleHttp\Message\Response $response */
$response = $httpClient->post('https://test.dev/app_dev.php/rest?a=b', [
    'json'        => array('a' => 'b'),
    'subscribers' => array($hawkAuthenticationPlugin),
]);