PHPackages                             stojankukrika/oauth2-freshbooks - 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. stojankukrika/oauth2-freshbooks

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

stojankukrika/oauth2-freshbooks
===============================

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

1.0.0(4y ago)0506MITPHP

Since Dec 25Pushed 4y ago1 watchersCompare

[ Source](https://github.com/stojankukrika/oauth2-freshbooks)[ Packagist](https://packagist.org/packages/stojankukrika/oauth2-freshbooks)[ RSS](/packages/stojankukrika-oauth2-freshbooks/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (1)Dependencies (5)Versions (2)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/c6bb5cb4335fc17a59d9da2740f432ce96e1a5024dfd43458f4bf52594545318/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f73746f6a616e6b756b72696b612f6f61757468322d6672657368626f6f6b2f62616467652e7376673f6272616e63683d)](https://coveralls.io/github/stojankukrika/oauth2-freshbook?branch=)[![Build Status](https://camo.githubusercontent.com/bc711756c4dc38c7be332749a0ea1de01e5f0cb9f530276f5a96bd2c7e78ad27/68747470733a2f2f7472617669732d63692e636f6d2f73746f6a616e6b756b72696b612f6f61757468322d6672657368626f6f6b732e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/stojankukrika/oauth2-freshbooks)[![Total Downloads](https://camo.githubusercontent.com/bc7ca95cb9aa3e3ce0798c25b2450eade3eeefe641ed401ca1c298da58cbc15a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73746f6a616e6b756b72696b612f6f61757468322d6672657368626f6f6b732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/stojankukrika/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 stojankukrika/oauth2-freshbooks

```

Usage
-----

[](#usage)

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

### Authorization Code Flow

[](#authorization-code-flow)

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

$grant = new \Stojankukrika\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/stojankukrika/oauth2-freshbooks/blob/master/CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

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

License
-------

[](#license)

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

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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

Unknown

Total

1

Last Release

1600d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/79d2b7ee98d72f99645b3c270bcffe40e8176ec39e449127de18075c8fb173bf?d=identicon)[stojankukrika](/maintainers/stojankukrika)

---

Top Contributors

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

---

Tags

clientoauthoauth2authorizationauthorisationfreshbooks

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/stojankukrika-oauth2-freshbooks/health.svg)

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

###  Alternatives

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