auth

Summary

Pass an array of HTTP authentication parameters to use with the request. The array must contain the username in index [0], the password in index [1], and you can optionally provide a built-in authentication type in index [2]. Pass null to disable authentication for a request.

Types

  • array
  • string
  • null

Default

None

Constant

GuzzleHttp\RequestOptions::AUTH

The built-in authentication types are as follows:

basic

Use basic HTTP authentication in the Authorization header (the default setting used if none is specified).

  1. $client->request('GET', '/get', ['auth' => ['username', 'password']]);

digest

Use digest authentication (must be supported by the HTTP handler).

  1. $client->request('GET', '/get', [
  2. 'auth' => ['username', 'password', 'digest']
  3. ]);

Note

This is currently only supported when using the cURL handler, but creating a replacement that can be used with any HTTP handler is planned.

ntlm

Use Microsoft NTLM authentication.aspx) (must be supported by the HTTP handler).

  1. $client->request('GET', '/get', [
  2. 'auth' => ['username', 'password', 'ntlm']
  3. ]);

Note

This is currently only supported when using the cURL handler.