PHPackages                             kahu/oauth2-client - 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. kahu/oauth2-client

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

kahu/oauth2-client
==================

Kahu.app OAuth2 Client

v1.1.0(2y ago)0451MITPHPPHP ^8.2

Since Jun 30Pushed 2y agoCompare

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

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

Kahu Provider for OAuth 2.0 Client
==================================

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

This package provides Kahu 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 kahu/oauth2-client
```

Usage
-----

[](#usage)

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

### Authorization Code Flow

[](#authorization-code-flow)

```
$provider = new Kahu\OAuth2\Client\Provider\Kahu(
  [
    'clientId' => '{kahu-client-id}',
    'clientSecret' => '{kahu-client-secret}',
    'redirectUri' => 'https://example.com/callback-url'
  ]
);

// If we don't have an authorization code then get one
if (isset($_GET['code']) === false) {
  $authUrl = $provider->getAuthorizationUrl();
  $_SESSION['oauth2state'] = $provider->getState();
  header('Location: ' . $authUrl);
  exit;
}

// Check given state against previously stored one to mitigate CSRF attack
if (empty($_GET['state']) || $_GET['state'] !== $_SESSION['oauth2state']) {
  unset($_SESSION['oauth2state']);
  exit('Invalid state');
}

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

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

License
-------

[](#license)

This project is licensed under the [MIT License](LICENSE).

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity57

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

Total

2

Last Release

961d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/42b9c9cbc06973a61587667fc811b853f4d71843f35ba2535f3900083e69ab3f?d=identicon)[flavioheleno](/maintainers/flavioheleno)

---

Top Contributors

[![flavioheleno](https://avatars.githubusercontent.com/u/471860?v=4)](https://github.com/flavioheleno "flavioheleno (9 commits)")

---

Tags

oauth2oauth2-clientsingle-sign-onclientoauthoauth2authorizationkahukahu.app

### Embed Badge

![Health badge](/badges/kahu-oauth2-client/health.svg)

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

###  Alternatives

[league/oauth2-google

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

41721.2M118](/packages/league-oauth2-google)[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)[mollie/oauth2-mollie-php

Mollie Provider for OAuth 2.0 Client

251.7M1](/packages/mollie-oauth2-mollie-php)[omines/oauth2-gitlab

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

36721.5k13](/packages/omines-oauth2-gitlab)

PHPackages © 2026

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