How to do HTTP basic auth with Laravel and Guzzle

Here is a snippet that allows you to do basic auth:

$client = new Client();

$response = $client->request(
    'POST', /*instead of POST, you can use GET, PUT, DELETE, etc*/
      'auth' => ['username', 'password'] /*if you don't need to use a password, just leave it null*/

echo $response->getBody();


Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top