PHPackages                             zerospam/oauth2-freshbook - 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. zerospam/oauth2-freshbook

Abandoned → [zerospam/oauth2-freshbooks](/?search=zerospam%2Foauth2-freshbooks)Library[Authentication &amp; Authorization](/categories/authentication)

zerospam/oauth2-freshbook
=========================

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

1.6.1(7y ago)3171[2 issues](https://github.com/zerospam/oauth2-freshbook/issues)MITPHP

Since May 29Pushed 7y ago2 watchersCompare

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

READMEChangelogDependencies (5)Versions (6)Used By (0)

Freshbooks Provider for OAuth 2.0 Client
========================================

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

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Coverage Status](https://camo.githubusercontent.com/e4dad6f09ce7b3a164d18ab77b3acabd89b6ba3629c58b7c377ee90e57649a40/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7a65726f7370616d2f6f61757468322d6672657368626f6f6b2f62616467652e7376673f6272616e63683d)](https://coveralls.io/github/zerospam/oauth2-freshbook?branch=)[![Build Status](https://camo.githubusercontent.com/a2b707a0b543712e9d088fabda88feb513b7271a4c002a08ba68792833ef3946/68747470733a2f2f7472617669732d63692e636f6d2f7a65726f7370616d2f6f61757468322d6672657368626f6f6b732e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/zerospam/oauth2-freshbooks)[![Total Downloads](https://camo.githubusercontent.com/e55d2b999f8030cdb5513141db885a9df1e9343f965b4b29236a1f8cfecc7441/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a65726f7370616d2f6f61757468322d6672657368626f6f6b732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zerospam/oauth2-freshbooks)

This package provides Freshbooks 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 zerospam/oauth2-freshbooks

```

Usage
-----

[](#usage)

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

### Authorization Code Flow

[](#authorization-code-flow)

```
$provider = new ZEROSPAM\OAuth2\Client\Provider\FreshBooks([
    'clientId'          => '{freshbooks-client-id}',
    'clientSecret'      => '{freshbooks-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->getId());

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

### Refreshing a Token

[](#refreshing-a-token)

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

$grant = new \League\OAuth2\Client\Grant\RefreshToken();
$token = $provider->getAccessToken($grant, ['refresh_token' => $token->refreshToken]);
```

Testing
-------

[](#testing)

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

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

[](#contributing)

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

Credits
-------

[](#credits)

- [Antoine Aflalo](https://github.com/Belphemur)
- [All Contributors](https://github.com/zerospam/oauth2-freshbooks/contributors)

License
-------

[](#license)

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

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance7

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity67

Established project with proven stability

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

Total

5

Last Release

2904d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f182d00d821dc7d497f5140f377a09d67ea8b490f1bbc73a6523faf814658501?d=identicon)[ZEROSPAM](/maintainers/ZEROSPAM)

---

Top Contributors

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

---

Tags

freshbooksoauth2clientoauthoauth2authorizationauthorisationfreshbooks

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/zerospam-oauth2-freshbook/health.svg)

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

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