PHPackages                             healyhatman/oauth2-keypay - 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. healyhatman/oauth2-keypay

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

healyhatman/oauth2-keypay
=========================

Provider for the OAuth 2 client

1.1(3y ago)01.7k—0%1MITPHPPHP ^7.4 || ^8.0

Since Sep 8Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Healyhatman/oauth2-keypay)[ Packagist](https://packagist.org/packages/healyhatman/oauth2-keypay)[ Docs](https://github.com/healyhatman/oauth2-keypay)[ GitHub Sponsors](https://github.com/:vendor_name)[ RSS](/packages/healyhatman-oauth2-keypay/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (4)Used By (1)

KeyPay Provider for OAuth 2.0 Client
====================================

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

[![Latest Version on Packagist](https://camo.githubusercontent.com/ddf00681a2738068822950d9255400f07523889aa4b3ffc47de592f93e07cf6a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6865616c796861746d616e2f6f61757468322d6b65797061792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/healyhatman/oauth2-keypay)[![GitHub Tests Action Status](https://camo.githubusercontent.com/c3607382debcb17b4d462f441c832d223aa3da8256d959960973fe205e078879/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6865616c796861746d616e2f6f61757468322d6b65797061792f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/healyhatman/oauth2-keypay/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/ddee19d3fe4ba5facc26b00fd2488b373ddec6ec102a27d94fa814d272c42cc6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6865616c796861746d616e2f6f61757468322d6b65797061792f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/vendor_slug/package_slug/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/7625bf39ff031b2a7e33985354dc3d8d51672f46c8f3a52684a44cd9445a2508/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6865616c796861746d616e2f6f61757468322d6b65797061792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vendor_slug/package_slug)

This package provides KeyPay OAuth 2.0 support for the PHP League's OAuth 2.0 Client

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

[](#installation)

You can install the package via composer:

```
composer require healyhatman/oauth2-keypay
```

Usage
-----

[](#usage)

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

### Authorisation Code Flow

[](#authorisation-code-flow)

```
session_start();

$provider = new \Healyhatman\Oauth2\Client\Provider\KeyPay([
    'clientId'     => '{your KeyPay client ID}',
    'clientSecret' => '{your KeyPay client secret}',
    'clientId'     => '{your KeyPay redirect URI}'
]);

if (!isset($_GET['code'])) {

    // If we don't have an authorization code then get one
    $authUrl = $provider->getAuthorizationUrl(['scope' => '']);

    $_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']
    ]);
}

```

You can then store the token to make requests

Refreshing a Token
------------------

[](#refreshing-a-token)

```
$newAccessToken = $provider->getAccessToken('refresh_token', [
    'refresh_token' => $access->refresh_token
]);

```

Testing
-------

[](#testing)

I haven't made anything for that yet. One day! Maybe.

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

[](#contributing)

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

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Kamron Brooks](https://github.com/:healyhatman)
- [All Contributors](../../contributors)

### Special Thanks

[](#special-thanks)

- [Calcinai](https://github.com/:calcinai)

License
-------

[](#license)

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

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

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

Every ~293 days

Total

2

Last Release

1420d ago

PHP version history (2 changes)v1.0PHP ^7.4

1.1PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/1c0ad757d9bf442e77510d23b6324ef029892601200bbe5eb2b251bd6a3acfe4?d=identicon)[Healyhatman](/maintainers/Healyhatman)

---

Top Contributors

[![Healyhatman](https://avatars.githubusercontent.com/u/13272508?v=4)](https://github.com/Healyhatman "Healyhatman (21 commits)")

---

Tags

healyhatmankeypay

### Embed Badge

![Health badge](/badges/healyhatman-oauth2-keypay/health.svg)

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

###  Alternatives

[league/oauth2-google

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

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

Integration with league/oauth2-client to provide services

84016.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)
