Authentication PluginΒΆ

This plugin uses the authentication component from php-http/message to authenticate requests sent through the client:

use Http\Discovery\HttpClientDiscovery;
use Http\Message\Authentication\BasicAuth;
use Http\Client\Common\PluginClient;
use Http\Client\Common\Plugin\AuthenticationPlugin;

$authentication = new BasicAuth('username', 'password');
$authenticationPlugin = new AuthenticationPlugin($authentication);

$pluginClient = new PluginClient(
    HttpClientDiscovery::find(),
    [$authenticationPlugin]
);

Check the authentication component documentation for the list of available authentication methods.