PHPackages                             openpublicmedia/oauth2-pbs - 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. openpublicmedia/oauth2-pbs

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

openpublicmedia/oauth2-pbs
==========================

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

v2.0.0(1y ago)11.1k↓27.8%MITPHPCI failing

Since Jan 31Pushed 1y ago4 watchersCompare

[ Source](https://github.com/OpenPublicMedia/oauth2-pbs)[ Packagist](https://packagist.org/packages/openpublicmedia/oauth2-pbs)[ RSS](/packages/openpublicmedia-oauth2-pbs/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (5)Versions (9)Used By (0)

PBS Provider for Public Media SSO Client
========================================

[](#pbs-provider-for-public-media-sso-client)

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

Legacy PBS OAuth 2.0
--------------------

[](#legacy-pbs-oauth-20)

For legacy PBS OAuth 2.0 support, use a 1.x versions of this library.

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

[](#installation)

To install, use composer:

```
composer require openpublicmedia/oauth2-pbs
```

Usage
-----

[](#usage)

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

### Authorization Code Flow

[](#authorization-code-flow)

```
$provider = new OpenPublicMedia\OAuth2\Client\Provider\Pbs([
    'clientId'          => '{pbs-client-id}',
    'customerId'        => '{pbs-customer-id}',
    '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();

    // Add PKCE code to session.
    $_SESSION['oauth2pkceCode'] = $provider->getPkceCode();

    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 {

    // Restore the PKCE code stored in the session.
    $provider->setPkceCode($_SESSION['oauth2pkceCode']);

    // 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->getFirstName());

    } 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();
}
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Christopher C. Wells](https://www.chris-wells.net)
- [All Contributors](https://github.com/openpublicmedia/oauth2-pbs/graphs/contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity66

Established project with proven stability

 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 ~302 days

Recently: every ~473 days

Total

8

Last Release

597d ago

Major Versions

v1.0.6 → v2.0.02024-11-15

### Community

Maintainers

![](https://www.gravatar.com/avatar/bff91dfe597545a4f54945ec9aee22330bf39fd981466accfa486ede2b573abc?d=identicon)[cdubz](/maintainers/cdubz)

---

Top Contributors

[![cdubz](https://avatars.githubusercontent.com/u/10456740?v=4)](https://github.com/cdubz "cdubz (16 commits)")

---

Tags

oauth2oauth2-providerphpclientoauthoauth2authorizationauthorisationpbs

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/openpublicmedia-oauth2-pbs/health.svg)

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

###  Alternatives

[stevenmaguire/oauth2-keycloak

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

2306.4M45](/packages/stevenmaguire-oauth2-keycloak)[thenetworg/oauth2-azure

Azure Active Directory OAuth 2.0 Client Provider for The PHP League OAuth2-Client

25310.7M83](/packages/thenetworg-oauth2-azure)[patrickbussmann/oauth2-apple

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

1152.8M12](/packages/patrickbussmann-oauth2-apple)[omines/oauth2-gitlab

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

36779.2k16](/packages/omines-oauth2-gitlab)[league/oauth2-instagram

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

661.1M48](/packages/league-oauth2-instagram)[mollie/oauth2-mollie-php

Mollie Provider for OAuth 2.0 Client

261.8M1](/packages/mollie-oauth2-mollie-php)

PHPackages © 2026

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