PHPackages                             schoolrunner/oauth2-clever - 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. schoolrunner/oauth2-clever

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

schoolrunner/oauth2-clever
==========================

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

3.0(3y ago)323.2k3[1 PRs](https://github.com/Schoolrunner/oauth2-clever/pulls)MITPHP

Since Jun 28Pushed 3y ago7 watchersCompare

[ Source](https://github.com/Schoolrunner/oauth2-clever)[ Packagist](https://packagist.org/packages/schoolrunner/oauth2-clever)[ RSS](/packages/schoolrunner-oauth2-clever/feed)WikiDiscussions develop Synced 1mo ago

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

Clever Provider for OAuth 2.0 Client
====================================

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

[![CirclCI](https://camo.githubusercontent.com/99c975be4e51c46f261c43c56516ad3f8f76ac387064a212a382cc1ef91f546e/68747470733a2f2f696d672e736869656c64732e696f2f636972636c6563692f70726f6a6563742f5363686f6f6c72756e6e65722f6f61757468322d636c657665722e737667)](https://circleci.com/gh/Schoolrunner/oauth2-clever)[![License](https://camo.githubusercontent.com/3ca5ba1300ba36647f4583dc42ad9282b3b2bc4f7907e49b61c6a74587b7bc81/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7363686f6f6c72756e6e65722f6f61757468322d636c657665722e737667)](https://github.com/schoolrunner/oauth2-cleover/blob/master/LICENSE)[![Latest Stable Version](https://camo.githubusercontent.com/238de85002b5e313093b0a6fcfae45a3aefffa39999c0c6fac3de90ae6998f27/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7363686f6f6c72756e6e65722f6f61757468322d636c657665722e737667)](https://packagist.org/packages/schoolrunner/oauth2-clever)

This package provides [Clever OAuth 2.0](https://dev.clever.com/instant-login/bearer-tokens) support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).

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

[](#installation)

To install, use composer:

```
composer require schoolrunner/oauth2-clever

```

Usage
-----

[](#usage)

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

### Authorization Code Flow

[](#authorization-code-flow)

```
$provider = new Schoolrunner\OAuth2\Client\Provider\Clever([
    'clientId'     => '{clever-client-id}',
    'clientSecret' => '{clever-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->state;
    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
        $userDetails = $provider->getUserDetails($token);

        // Use these details to create a new profile
        printf('Hello %s!', $userDetails->getName());

    } catch (Exception $e) {

        // Failed to get user details
        exit('Oh dear...');
    }

    // Use this to interact with an API on the users behalf
    echo $token->accessToken;

}
```

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

[](#refreshing-a-token)

Clever does not use refresh tokens.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 75% 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 ~598 days

Total

5

Last Release

1217d ago

Major Versions

1.2 → 2.02017-06-14

2.0 → 3.02023-01-17

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/597004?v=4)[Chris smoak](/maintainers/smoakey)[@smoakey](https://github.com/smoakey)

![](https://avatars.githubusercontent.com/u/12090746?v=4)[Sam Genduso](/maintainers/sgenduso)[@sgenduso](https://github.com/sgenduso)

![](https://www.gravatar.com/avatar/07c0ac88f3d298d9f4dfce6bb5e156db1630053883e4c5f17298b8d2c54c20e2?d=identicon)[SchoolrunnerOps](/maintainers/SchoolrunnerOps)

---

Top Contributors

[![smoakey](https://avatars.githubusercontent.com/u/597004?v=4)](https://github.com/smoakey "smoakey (6 commits)")[![kris-castillo-dev](https://avatars.githubusercontent.com/u/192042768?v=4)](https://github.com/kris-castillo-dev "kris-castillo-dev (1 commits)")[![MorpheusZero](https://avatars.githubusercontent.com/u/5752785?v=4)](https://github.com/MorpheusZero "MorpheusZero (1 commits)")

---

Tags

clientAuthenticationoauthoauth2authorizationclever

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/schoolrunner-oauth2-clever/health.svg)

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

###  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)
