PHPackages                             damien-unsolite/oauth2-factorial - 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. damien-unsolite/oauth2-factorial

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

damien-unsolite/oauth2-factorial
================================

Factorial Provider for OAuth 2.0 Client

v0.9.3(2y ago)070MITPHP

Since Oct 30Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Damien-Unsolite/oauth2-factorial)[ Packagist](https://packagist.org/packages/damien-unsolite/oauth2-factorial)[ RSS](/packages/damien-unsolite-oauth2-factorial/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (5)Used By (0)

Factorial Provider for OAuth 2.0 Client
=======================================

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

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

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

[](#installation)

```
composer require Damien-Unsolite/oauth2-factorial

```

Usage
-----

[](#usage)

```
$factorialProvider = new \DamienUnsolite\OAuth2\Client\Provider\Factorial([
    'clientId'                => 'yourId',          // The client ID assigned to you by Factorial
    'clientSecret'            => 'yourSecret',      // The client password assigned to you by Factorial
    'redirectUri'             => 'yourRedirectUri'  // The return URL you specified for your app on Factorial
]);

// Get authorization code
if (!isset($_GET['code'])) {
    // Options are optional, defaults to 'profile' only
    $options = ['scope' => 'profile postal_code payments:widget payments:shipping_address payments:billing_address'];
    // Get authorization URL
    $authorizationUrl = $factorialProvider->getAuthorizationUrl($options);

    // Get state and store it to the session
    $_SESSION['oauth2state'] = $factorialProvider->getState();

    // Redirect user to authorization URL
    header('Location: ' . $authorizationUrl);
    exit;
// Check for errors
} elseif (empty($_GET['state']) || (isset($_SESSION['oauth2state']) && $_GET['state'] !== $_SESSION['oauth2state'])) {
    if (isset($_SESSION['oauth2state'])) {
        unset($_SESSION['oauth2state']);
    }
    exit('Invalid state');
} else {
    // Get access token
    try {
        $accessToken = $factorialProvider->getAccessToken(
            'authorization_code',
            [
                'code' => $_GET['code']
            ]
        );
    } catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {
        exit($e->getMessage());
    }

    // Get resource owner
    try {
        $resourceOwner = $factorialProvider->getResourceOwner($accessToken);
    } catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {
        exit($e->getMessage());
    }

    // Now you can store the results to session etc.
    $_SESSION['accessToken'] = $accessToken;
    $_SESSION['resourceOwner'] = $resourceOwner;

    var_dump(
        $resourceOwner->getId(),
        $resourceOwner->getName(),
        $resourceOwner->getPostalCode(),
        $resourceOwner->getEmail(),
        $resourceOwner->toArray()
    );
}
```

For more information see the PHP League's general usage examples.

Testing
-------

[](#testing)

```
$ ./vendor/bin/phpunit
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/Damien-Unsolite/oauth2-factorial/blob/main/LICENSE) for more information.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

4

Last Release

924d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/35c9c0b81063a8db410bc99363a70bf9cd2287064381251d5d4c382a108866a0?d=identicon)[Damien-Unsolite](/maintainers/Damien-Unsolite)

---

Top Contributors

[![Damien-Unsolite](https://avatars.githubusercontent.com/u/54817926?v=4)](https://github.com/Damien-Unsolite "Damien-Unsolite (7 commits)")

---

Tags

phpapiclientAuthenticationoauthoauth2authorizationfactorial

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/damien-unsolite-oauth2-factorial/health.svg)

```
[![Health](https://phpackages.com/badges/damien-unsolite-oauth2-factorial/health.svg)](https://phpackages.com/packages/damien-unsolite-oauth2-factorial)
```

###  Alternatives

[league/oauth2-google

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

41721.2M118](/packages/league-oauth2-google)[league/oauth2-facebook

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

32013.0M66](/packages/league-oauth2-facebook)[andalisolutions/oauth2-anaf

Anaf OAuth 2.0 support for the PHP League's OAuth 2.0 Client

194.1k](/packages/andalisolutions-oauth2-anaf)

PHPackages © 2026

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