PHPackages                             prestashopcorp/oauth2-prestashop - 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. prestashopcorp/oauth2-prestashop

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

prestashopcorp/oauth2-prestashop
================================

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

v2.0.0(1y ago)011.6k↓50%[1 PRs](https://github.com/PrestaShopCorp/oauth2-prestashop/pulls)MITPHPPHP &gt;=5.6

Since Oct 4Pushed 1y ago8 watchersCompare

[ Source](https://github.com/PrestaShopCorp/oauth2-prestashop)[ Packagist](https://packagist.org/packages/prestashopcorp/oauth2-prestashop)[ RSS](/packages/prestashopcorp-oauth2-prestashop/feed)WikiDiscussions main Synced 1mo ago

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

PrestaShop Provider for OAuth 2.0 Client
========================================

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

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

[![Source Code](https://camo.githubusercontent.com/af3d1798e121131d4276eba2bfedd6d2076aa2b177150edb9ffb65a094c2333a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736f757263652d50726573746153686f70436f72702f6f61757468322d2d70726573746173686f702d626c75652e7376673f7374796c653d666c61742d737175617265)](https://github.com/PrestaShopCorp/oauth2-prestashop)[![Latest Version](https://camo.githubusercontent.com/8381643f338665f763d9075cc32f52be585b87f9dce03444ca3712fd4e971f59/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f50726573746153686f70436f72702f6f61757468322d70726573746173686f702e7376673f7374796c653d666c61742d737175617265)](https://github.com/PrestaShopCorp/oauth2-prestashop/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/PrestaShopCorp/oauth2-prestashop/blob/main/LICENSE)[![Build Status](https://camo.githubusercontent.com/96be7857ca014c73582bb31b8cf7df9c71b15204f0c4368088773fa3d7ed1fb7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f50726573746153686f70436f72702f6f61757468322d70726573746173686f702f2e6769746875622f776f726b666c6f77732f7068702e796d6c3f6c6162656c3d4349266c6f676f3d676974687562267374796c653d666c61742d737175617265)](https://github.com/PrestaShopCorp/oauth2-prestashop/actions?query=workflow%3ACI)[![Total Downloads](https://camo.githubusercontent.com/f564b5a235d8c4eb5e367a237fc5fdfc37522cace8361b70fce07b205adcd391/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f50726573746153686f70436f72702f6f61757468322d70726573746173686f702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/prestashopcorp/oauth2-prestashop)

---

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

[](#installation)

```
composer require prestashopcorp/oauth2-prestashop

```

Usage
-----

[](#usage)

```
$prestaShopProvider = new \PrestaShop\OAuth2\Client\Provider\PrestaShop([
    'clientId' => 'yourClientId', // The client ID assigned to you by PrestaShop
    'clientSecret' => 'yourClientSecret', // The client password assigned to you by PrestaShop
    'redirectUri' => 'yourClientRedirectUri', // The URL responding to the code flow implemented here
    // Optional parameters
    'uiLocales' => ['fr-FR', 'en'],
    'acrValues' => ['prompt:create'], // In that specific case we change the default prompt to the "register" page
]);

if (!empty($_GET['error'])) {
    // Got an error, probably user denied access
    exit($_GET['error']);

// If we don't have an authorization code then get one
} elseif (!isset($_GET['code'])) {
    $authorizationUrl = $prestaShopProvider->getAuthorizationUrl($options);

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

    // Redirect user to authorization URL
    header('Location: ' . $authorizationUrl);
    exit;

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

    if (isset($_SESSION['oauth2state'])) {
        unset($_SESSION['oauth2state']);
    }

    exit('Invalid state');

} else {
    try {
        // Try to get an access token (using the authorization code grant)
        $accessToken = $prestaShopProvider->getAccessToken('authorization_code', [
            'code' => $_GET['code']
        ]);

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

        // Get resource owner
        $prestaShopUser = $provider->getResourceOwner($accessToken);

        var_dump(
            $prestaShopUser->getId(),
            $prestaShopUser->getName(),
            $prestaShopUser->getEmail(),
            $prestaShopUser->getEmailVerified(),
            $prestaShopUser->getPicture(),
            $prestaShopUser->toArray()
        );

    } catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {
        exit($e->getMessage());
    }
}
```

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

Logout flow
-----------

[](#logout-flow)

Going beyond the scope of this library we provide a helper function `getLogoutUrl` to logout from your oauth2 session.

The only required parameter is `id_token_int` here, you can optionally provide `post_logout_redirect_uri` to override the one from the constructor.

Also don't forget to provide `postLogoutCallbackUri` at construction time if you plan to use it.

```
$prestaShopProvider = new \PrestaShop\OAuth2\Client\Provider\PrestaShop([
    'clientId' => 'yourClientId', // The client ID assigned to you by PrestaShop
    'clientSecret' => 'yourClientSecret', // The client password assigned to you by PrestaShop
    'redirectUri' => 'yourClientRedirectUri', // The URL responding to the code flow implemented here
    'postLogoutCallbackUri' => 'yourLogoutCallbackUri', // Logout url whitelisted among the ones defined with your client
    // Optional parameters
    'uiLocales' => ['fr-FR', 'en'],
    'acrValues' => ['prompt:create'], // In that specific case we change the default prompt to the "register" page
]);

if (isset($_GET['oauth2Callback')) {
    // your logout code
    session_destroy();

} else {
    /** @var \League\OAuth2\Client\Token\AccessToken $accessToken */
    $accessToken = $_SESSION['accessToken'];

    // The only required parameter is "id_token_int" here,
    // you can optionally provide "post_logout_redirect_uri" to override the one from the constructor.
    $logoutUrl = $prestaShopProvider->getLogoutUrl([
        'id_token_hint' => $accessToken->getValues()['id_token'],
        // (Optionnal here) Logout url whitelisted among the ones defined with your client
        // 'post_logout_redirect_uri' => 'https://my-logout-url/?oauth2Callback',
    ]);

    header('Location: ' . $logoutUrl);
    exit;
}
```

Testing
-------

[](#testing)

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

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/prestashopcorp/oauth2-prestashop/blob/master/LICENSE) for more information.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.5% 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 ~297 days

Total

3

Last Release

721d ago

Major Versions

v1.1.0 → v2.0.02024-05-22

PHP version history (2 changes)v1.0.0PHP &gt;=7.1

v2.0.0PHP &gt;=5.6

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15106407?v=4)[Jarvis](/maintainers/ps-jarvis)[@ps-jarvis](https://github.com/ps-jarvis)

---

Top Contributors

[![hschoenenberger](https://avatars.githubusercontent.com/u/54308193?v=4)](https://github.com/hschoenenberger "hschoenenberger (37 commits)")[![emmanuelgautier](https://avatars.githubusercontent.com/u/2765366?v=4)](https://github.com/emmanuelgautier "emmanuelgautier (3 commits)")

---

Tags

phpapiclientAuthenticationoauthoauth2authorizationprestashop

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/prestashopcorp-oauth2-prestashop/health.svg)

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

###  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)
