Example: Configuring HTTP Basic Auth

edit

Example: Configuring HTTP Basic Auth

edit

HTTP basic authentication is a very common requirement. To enable Basic Auth in the client, simply set a parameter with the required auth parameters:

$params = array();
$params['connectionParams']['auth'] = array(
    'username',
    'password',
    'Basic' 
);
$client = new Elasticsearch\Client($params);

Accepts four different options: Basic, Digets, NTLM, Any

After being initialized with authentication credentials, all outgoing requests will automatically include the HTTP auth headers.