Authentication middlewares to support access to the mite API
This package is no longer maintained. Use https://github.com/jeromegamez/mite-php instead
composer require gamez/mite-api-authentication
http://docs.guzzlephp.org/en/stable/handlers-and-middleware.html
use Gamez\Mite\MiteAuthenticationMiddleware;
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
$stack = HandlerStack::create();
$stack->push(new MiteAuthenticationMiddleware('accountname', 'apikey'));
$client = new Client(['handler' => $stack]);
http://docs.php-http.org/en/latest/plugins/authentication.html
use Gamez\Mite\MiteAuthentication;
use Http\Discovery\HttpClientDiscovery;
use Http\Message\Authentication\BasicAuth;
use Http\Client\Common\PluginClient;
use Http\Client\Common\Plugin\AuthenticationPlugin;
$authentication = new MiteAuthentication('accountname', 'apikey');
$authenticationPlugin = new AuthenticationPlugin($authentication);
$client = new PluginClient(
HttpClientDiscovery::find(),
[$authenticationPlugin]
);
use Gamez\Mite\MiteRequestAuthenticator;
$authenticator = new MiteRequestAuthenticator('accountname', 'apikey');
$request = ...; // an implementation of Psr\Http\Message\RequestInterface
$authenticatedRequest = $authenticator->authenticate($request);