Auth0 API client authentication for the Symfony HTTP client.

3.0.0 2024-03-08 10:35 UTC


Latest version on Packagist Software License Build Status Coverage Status Code Quality

Auth0 API client authentication for the Symfony HTTP client.

Installation using Composer

Run the following command to add the package to the composer.json of your project:

$ composer require superbrave/auth0-http-client symfony/http-client

The symfony/http-client can be replaced with any other HTTP client implementing the Symfony HTTP client contracts.


The following example shows how to create the instances required to do an API call authenticated through Auth0:


use Superbrave\AuthZeroHttpClient\AuthZeroAuthenticatingHttpClient;
use Superbrave\AuthZeroHttpClient\AuthZeroConfiguration;
use Symfony\Component\HttpClient\HttpClient;

$httpClient = HttpClient::create();
$authZeroConfiguration = new AuthZeroConfiguration(
    '', // Your Auth0 tenant URL
    'clientId',                      // Your application's Client ID
    'clientSecret',                  // Your application's Client Secret
    ''  // The unique identifier of the target API you want to access

$authZeroHttpClient = new AuthZeroAuthenticatingHttpClient($httpClient, $authZeroConfiguration);

$response = $authZeroHttpClient->request('GET', '');

Optionally, a custom cache instance can be injected into the AuthZeroAuthenticatingHttpClient. The cache will store the access tokens (JWT) for the configured TTL returned by Auth0.


The Auth0 HTTP client is licensed under the MIT License. Please see the LICENSE file for details.