PHPackages                             datlechin/oauth2-sepay - 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. datlechin/oauth2-sepay

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

datlechin/oauth2-sepay
======================

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

v1.0.0(1y ago)13MITPHPPHP ^7.4 || ^8.0CI passing

Since Feb 24Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/datlechin/oauth2-sepay)[ Packagist](https://packagist.org/packages/datlechin/oauth2-sepay)[ GitHub Sponsors](https://github.com/datlechin)[ RSS](/packages/datlechin-oauth2-sepay/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (7)Used By (0)

SePay Provider for OAuth 2.0 Client
===================================

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

[![Latest Version](https://camo.githubusercontent.com/7045451b44f55616c8a2a87db8a22959fc0fd97166abadb81057e53aa92a66b4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6461746c656368696e2f6f61757468322d73657061792e7376673f7374796c653d666c61742d737175617265)](https://github.com/datlechin/oauth2-sepay/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Coverage Status](https://camo.githubusercontent.com/014ecb701bc56cb188bba6f74a20f4f59d779a61bb71bef0a1968587de5b58c2/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6461746c656368696e2f6f61757468322d73657061792e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/datlechin/oauth2-sepay/code-structure)[![Quality Score](https://camo.githubusercontent.com/46841448a60c5e52af846caa630c53f1e98db15232d134bd7d93cab403528dfa/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6461746c656368696e2f6f61757468322d73657061792e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/datlechin/oauth2-sepay)[![Total Downloads](https://camo.githubusercontent.com/c410df5fa45b1a95af1e69bef4b5e972c54531eb86b385586542a2c9312f984f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6461746c656368696e2f6f61757468322d73657061792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/datlechin/oauth2-sepay)

This package provides SePay 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 datlechin/oauth2-sepay
```

Usage
-----

[](#usage)

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

### Authorization Code Flow

[](#authorization-code-flow)

```
$provider = new \Datlechin\OAuth2\Client\Provider\SePay([
    'clientId' => '{sepay-client-id}',
    'clientSecret' => '{sepay-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->getFullName());
    } 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 SePay authorization URL, you can specify the state and scopes your application may authorize.

```
$options = [
    'state' => 'OPTIONAL_CUSTOM_CONFIGURED_STATE',
    'scope' => ['profile', 'company', 'bank-account:read'] // array or string; at least 'profile' is required
];

$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.

- profile
- company
- bank-account:read
- transaction:read
- webhook:read
- webhook:write
- webhook:delete

Testing
-------

[](#testing)

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

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

[](#contributing)

Please see [CONTRIBUTING](https://github.com/datlechin/oauth2-sepay/blob/main/CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Ngô Quốc Đạt](https://github.com/datlechin)
- [All Contributors](https://github.com/datlechin/oauth2-sepay/contributors)

License
-------

[](#license)

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

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance70

Regular maintenance activity

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

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

449d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b5dca3124d040fb5f1e59100485f3a23e42e4e4b1c6d89c5d4cd3e79d95f574e?d=identicon)[Ngô Quốc Đạt](/maintainers/Ng%C3%B4%20Qu%E1%BB%91c%20%C4%90%E1%BA%A1t)

---

Top Contributors

[![datlechin](https://avatars.githubusercontent.com/u/56961917?v=4)](https://github.com/datlechin "datlechin (20 commits)")

---

Tags

clientAuthenticationoauthoauth2authorizationSePay

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/datlechin-oauth2-sepay/health.svg)

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

###  Alternatives

[league/oauth2-google

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

42121.2M118](/packages/league-oauth2-google)[cakedc/oauth2-cognito

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

18597.7k](/packages/cakedc-oauth2-cognito)

PHPackages © 2026

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