PHPackages                             larabros/oauth2-psn - 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. larabros/oauth2-psn

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

larabros/oauth2-psn
===================

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

0.2.0(10y ago)224167[1 issues](https://github.com/larabros/oauth2-psn/issues)MITPHPPHP ^5.5.9 || ^7.0

Since Mar 21Pushed 9y ago3 watchersCompare

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

READMEChangelogDependencies (5)Versions (3)Used By (0)

oauth2-psn
==========

[](#oauth2-psn)

[![Latest Version on Packagist](https://camo.githubusercontent.com/c41fbe9f5b27cd054eb0569cca984c9de963b0d9a2e8335822137593dead8b3a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c61726162726f732f6f61757468322d70736e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/larabros/oauth2-psn)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/ca1b945b500f038e917bc7be739d6cd222e9f5d0552349cf279b928d5ac80f88/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6c61726162726f732f6f61757468322d70736e2f646576656c6f702e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/larabros/oauth2-psn)[![Coverage Status](https://camo.githubusercontent.com/6bbea9599eb8ca946b2064f89b66527f2b87907d184e604a1b296448285af1b8/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6c61726162726f732f6f61757468322d70736e2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/larabros/oauth2-psn/code-structure)[![Quality Score](https://camo.githubusercontent.com/9334be6f81610863284e312056b0625c0a50318f2bacf4829666e4aeda8d9dbb/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6c61726162726f732f6f61757468322d70736e2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/larabros/oauth2-psn)[![Total Downloads](https://camo.githubusercontent.com/47786188ff491cf9330c0d01cf3fb545f4d56923a1fd9838c3abc45c763eaa6c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c61726162726f732f6f61757468322d70736e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/larabros/oauth2-psn)

[![Build Status](https://camo.githubusercontent.com/397e380f6d45cce9b21a556457aeaf1b5b4f4b975dc31b1fe8fa9418d6a23542/687474703a2f2f7068702d6579652e636f6d2f62616467652f6c61726162726f732f6f61757468322d70736e2f7465737465642e7376673f7374796c653d666c61742d737175617265)](http://php-eye.com/package/larabros/oauth2-psn)[![PSR2 Conformance](https://camo.githubusercontent.com/c738df562247e9287dde5513e30252b8157be82bf53b5534a0a3ec4e728fea8c/68747470733a2f2f7374796c6563692e696f2f7265706f732f35343234323239372f736869656c64)](https://styleci.io/repos/54242297/)

PSN OAuth 2.0 Client Provider for the PHP League's [OAuth2-Client](https://github.com/thephpleague/oauth2-client), for PHP 5.5.9+.

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

[](#installation)

To install, use composer:

```
composer require larabros/oauth2-psn

```

Usage
-----

[](#usage)

Usage is the same as the League OAuth2 client, using `\League\OAuth2\Client\Provider\Psn` as the provider.

### Authorization Code Flow

[](#authorization-code-flow)

```
$provider = new League\OAuth2\Client\Provider\Psn([
    'clientId'          => '{psn-client-id}',
    'clientSecret'      => '{psn-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->getPsnId());

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

### Managing Scopes

[](#managing-scopes)

When creating your PSN authorization URL, you can specify the state and scopes your application may authorize.

```
$options = [
    'state' => 'OPTIONAL_CUSTOM_CONFIGURED_STATE',
    'scope' => ['psn:s2s'] // array or string
];

$authorizationUrl = $provider->getAuthorizationUrl($options);
```

If neither are defined, the provider will utilize internal defaults.

At the time of authoring this documentation, the following scopes are available:

- psn:s2s

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

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

[](#contributing)

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

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Hassan Khan](https://github.com/hassankhan)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

3701d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0a181955d984c0a6f0b1f28febe7691e0ef9f6e92e721439023bc6a8dc15695a?d=identicon)[hassankhan](/maintainers/hassankhan)

---

Top Contributors

[![hassankhan](https://avatars.githubusercontent.com/u/1781985?v=4)](https://github.com/hassankhan "hassankhan (11 commits)")

---

Tags

larabrosoauth2-psn

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/larabros-oauth2-psn/health.svg)

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

###  Alternatives

[league/oauth2-google

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

41721.2M118](/packages/league-oauth2-google)[knpuniversity/oauth2-client-bundle

Integration with league/oauth2-client to provide services

83416.7M61](/packages/knpuniversity-oauth2-client-bundle)[thenetworg/oauth2-azure

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

2509.6M48](/packages/thenetworg-oauth2-azure)[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)[microsoft/kiota-authentication-phpleague

Authentication provider for Kiota using the PHP League OAuth 2.0 client to authenticate against the Microsoft Identity platform

153.2M7](/packages/microsoft-kiota-authentication-phpleague)

PHPackages © 2026

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