PHPackages                             nilesuan/oauth2-harvest - 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. nilesuan/oauth2-harvest

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

nilesuan/oauth2-harvest
=======================

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

1.2.0(9y ago)54894[3 issues](https://github.com/nilesuan/oauth2-harvest/issues)MITPHPPHP &gt;=5.5.0

Since Jul 9Pushed 9y ago2 watchersCompare

[ Source](https://github.com/nilesuan/oauth2-harvest)[ Packagist](https://packagist.org/packages/nilesuan/oauth2-harvest)[ RSS](/packages/nilesuan-oauth2-harvest/feed)WikiDiscussions master Synced 2mo ago

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

Harvest Provider for OAuth 2.0 Client
=====================================

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

[![Latest Stable Version](https://camo.githubusercontent.com/1618725b182ecc3fe9adab3895e2081e1eba7a154b5c65aa490d14158e28b178/68747470733a2f2f706f7365722e707567782e6f72672f6e696c657375616e2f6f61757468322d686172766573742f762f737461626c65)](https://packagist.org/packages/nilesuan/oauth2-harvest)[![License](https://camo.githubusercontent.com/a4041d6dbe526d4195355c22e170b545696151586e89a915c62d65b474794e1f/68747470733a2f2f706f7365722e707567782e6f72672f6e696c657375616e2f6f61757468322d686172766573742f6c6963656e7365)](https://packagist.org/packages/nilesuan/oauth2-harvest)[![Build Status](https://camo.githubusercontent.com/63b4c6466970c6a15b0ee884e88fcbc810bc9bce85fdf0c0234c412e79238acd/68747470733a2f2f7472617669732d63692e6f72672f6e696c657375616e2f6f61757468322d686172766573742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/nilesuan/oauth2-harvest)[![Code Coverage](https://camo.githubusercontent.com/5d365be126e9dd763ac761e226ebbb2bbc11cc2f444e743db0179374773e71f9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6e696c657375616e2f6f61757468322d686172766573742f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/nilesuan/oauth2-harvest/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/bbb87876228c156f2e5699da6d6eb9696ce5672e139ca0254a8921854c405ca9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6e696c657375616e2f6f61757468322d686172766573742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/nilesuan/oauth2-harvest/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/48a3775d26ce27176a69dbc0155046146ae6c6db03c6883c6a7d448ae6d408ee/68747470733a2f2f706f7365722e707567782e6f72672f6e696c657375616e2f6f61757468322d686172766573742f646f776e6c6f616473)](https://packagist.org/packages/nilesuan/oauth2-harvest)

This package provides Harvest's 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 nilesuan/oauth2-harvest

```

Usage
-----

[](#usage)

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

### Authorization Code Flow

[](#authorization-code-flow)

```
$provider = new Nilesuan\OAuth2\Client\Provider\Harvest([
    'clientId'          => '{harvest-client-id}',
    'clientSecret'      => '{harvest-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->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->getToken();
}
```

Testing
-------

[](#testing)

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

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

[](#contributing)

Please see [CONTRIBUTING](https://github.com/nilesuan/oauth2-harvest/blob/master/CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Nile Suan](https://github.com/nilesuan)
- [All Contributors](https://github.com/nilesuan/oauth2-harvest/contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/nilesuan/oauth2-harvest/blob/master/LICENSE) for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance8

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 50% 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 ~3 days

Total

2

Last Release

3591d ago

### Community

Maintainers

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

---

Top Contributors

[![nilesuan](https://avatars.githubusercontent.com/u/4256888?v=4)](https://github.com/nilesuan "nilesuan (1 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

---

Tags

clientoauthoauth2authorizationauthorisationHarvest

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/nilesuan-oauth2-harvest/health.svg)

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

###  Alternatives

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