PHPackages                             lodge104/oauth2-auth0 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. lodge104/oauth2-auth0

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

lodge104/oauth2-auth0
=====================

Auth0 OAuth 2.0 Client Provider for The PHP League OAuth2-Client

v2.4.2(3y ago)02281MITPHPPHP ^7.3|^8.0

Since Mar 13Pushed 3y agoCompare

[ Source](https://github.com/Lodge104/oauth2-auth0)[ Packagist](https://packagist.org/packages/lodge104/oauth2-auth0)[ RSS](/packages/lodge104-oauth2-auth0/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (10)Used By (1)

Auth0 Provider for OAuth 2.0 Client
===================================

[](#auth0-provider-for-oauth-20-client)

[![Build Status](https://camo.githubusercontent.com/38b83e1290416da2c39aa8011f2d95b34908d54618061785bb79c7e15d45117f/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f5269736b696f46722f6f61757468322d61757468302e737667)](https://travis-ci.org/RiskioFr/oauth2-auth0)[![License](https://camo.githubusercontent.com/cb1e9c494617a8219e8ebbda1aac9b00d136bf7e8638a737e4d83e6014840278/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7269736b696f2f6f61757468322d61757468302e737667)](https://github.com/RiskioFr/oauth2-auth0/blob/master/LICENSE)[![Latest Stable Version](https://camo.githubusercontent.com/1b91f373fe29cfcedd8f00edde8165289e97ed7054b44fb5b855187c2ef015f3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7269736b696f2f6f61757468322d61757468302e737667)](https://packagist.org/packages/riskio/oauth2-auth0)

This package provides Auth0 OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).

Installation
------------

[](#installation)

To install, use composer:

```
composer require riskio/oauth2-auth0

```

Usage
-----

[](#usage)

Usage is the same as The League's OAuth client, using `Riskio\OAuth2\Client\Provider\Auth0` as the provider.

### Authorization Code Flow

[](#authorization-code-flow)

You have to provide some parameters to the provider:

- customDomain (optional):
    - description: Custom domain used for the Auth0 login - (I.e.: login.custom-domain.tld - It will be prefixed with https:// automatically. If this is set, the region and account parameters will be ignored.)
- region (optional):
    - description: Auth0 region
    - values:
        - Riskio\\OAuth2\\Client\\Provider\\Auth0::REGION\_US (default value)
        - Riskio\\OAuth2\\Client\\Provider\\Auth0::REGION\_EU
        - Riskio\\OAuth2\\Client\\Provider\\Auth0::REGION\_AU
        - Riskio\\OAuth2\\Client\\Provider\\Auth0::REGION\_JP
- account (required if customDomain is not set):
    - description: Auth0 account name
- clientId
    - description: The client ID assigned to you by the provider
- clientSecret
    - description: The client password assigned to you by the provider
- redirectUri

```
session_start();

$provider = new Riskio\OAuth2\Client\Provider\Auth0([
    'region'       => '{region}',
    'account'      => '{account}',
    'clientId'     => '{auth0-client-id}',
    'clientSecret' => '{auth0-client-secret}',
    'redirectUri'  => 'https://example.com/callback-url'
]);

if (!isset($_GET['code'])) {

    // If we don't have an authorization code then get one
    $authUrl = $provider->getAuthorizationUrl();
    $_SESSION['oauth2state'] = $provider->getState();
    header('Location: ' . $authUrl);
    exit;

// Check given state against previously stored one to mitigate CSRF attack
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {

    unset($_SESSION['oauth2state']);
    exit('Invalid state');

} else {

    // Try to get an access token (using the authorization code grant)
    $token = $provider->getAccessToken('authorization_code', [
        'code' => $_GET['code']
    ]);

    // Optional: Now you have a token you can look up a users profile data
    try {

        // We got an access token, let's now get the user's details
        $user = $provider->getResourceOwner($token);

        // Use these details to create a new profile
        printf('Hello %s!', $user->getName());

    } catch (Exception $e) {

        // Failed to get user details
        exit('Oh dear...');
    }

    // Use this to interact with an API on the users behalf
    echo $token->getToken();
}
```

Refreshing a Token
------------------

[](#refreshing-a-token)

Auth0's OAuth implementation does not use refresh tokens.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 78.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~347 days

Recently: every ~273 days

Total

9

Last Release

1300d ago

Major Versions

v0.1.0 → v1.0.02017-08-27

v1.0.0 → v2.0.02017-08-28

PHP version history (3 changes)v0.1.0PHP &gt;=5.4.0

v2.0.0PHP &gt;=5.6.0

v2.4.0PHP ^7.3|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/1deaab31eb2e2350f8d940a688e575f071fbef536c2fe10f8767a94a82136672?d=identicon)[lodge104](/maintainers/lodge104)

---

Top Contributors

[![neeckeloo](https://avatars.githubusercontent.com/u/1768645?v=4)](https://github.com/neeckeloo "neeckeloo (30 commits)")[![smatyas](https://avatars.githubusercontent.com/u/534550?v=4)](https://github.com/smatyas "smatyas (4 commits)")[![floatflower](https://avatars.githubusercontent.com/u/11524498?v=4)](https://github.com/floatflower "floatflower (2 commits)")[![edwardsmarkf](https://avatars.githubusercontent.com/u/2924002?v=4)](https://github.com/edwardsmarkf "edwardsmarkf (1 commits)")[![rojtjo](https://avatars.githubusercontent.com/u/1123887?v=4)](https://github.com/rojtjo "rojtjo (1 commits)")

---

Tags

clientoauthoauth2authorizationauthorisationauth0

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lodge104-oauth2-auth0/health.svg)

```
[![Health](https://phpackages.com/badges/lodge104-oauth2-auth0/health.svg)](https://phpackages.com/packages/lodge104-oauth2-auth0)
```

###  Alternatives

[stevenmaguire/oauth2-keycloak

Keycloak OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2275.9M27](/packages/stevenmaguire-oauth2-keycloak)[patrickbussmann/oauth2-apple

Sign in with Apple OAuth 2.0 Client Provider for The PHP League OAuth2-Client

1132.5M6](/packages/patrickbussmann-oauth2-apple)[riskio/oauth2-auth0

Auth0 OAuth 2.0 Client Provider for The PHP League OAuth2-Client

172.2M6](/packages/riskio-oauth2-auth0)[mollie/oauth2-mollie-php

Mollie Provider for OAuth 2.0 Client

251.7M1](/packages/mollie-oauth2-mollie-php)[omines/oauth2-gitlab

GitLab OAuth 2.0 Client Provider for The PHP League OAuth2-Client

36721.5k13](/packages/omines-oauth2-gitlab)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
