gamez / mite-api-authentication
Authentication middlewares to support access to the mite API
Fund package maintenance!
jeromegamez
Requires
- php: ^7.0
- psr/http-message: ^1.0
Requires (Dev)
- guzzlehttp/guzzle: ^6.0
- php-http/message: ^1.0
- phpunit/phpunit: ^6.0|^7.0
Suggests
- guzzlehttp/guzzle: For using the GuzzleHttp middleware
- php-http/client-common: For using the HTTPlug authentication
This package is auto-updated.
Last update: 2022-02-01 13:14:33 UTC
README
Authentication middlewares to support access to the mite API
This package is no longer maintained. Use https://github.com/jeromegamez/mite-php instead
Installation
composer require gamez/mite-api-authentication
Usage
Guzzle
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]);
HTTPlug
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] );
Custom
use Gamez\Mite\MiteRequestAuthenticator; $authenticator = new MiteRequestAuthenticator('accountname', 'apikey'); $request = ...; // an implementation of Psr\Http\Message\RequestInterface $authenticatedRequest = $authenticator->authenticate($request);