PHPackages                             bookingsync/oauth2-bookingsync-php - 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. bookingsync/oauth2-bookingsync-php

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

bookingsync/oauth2-bookingsync-php
==================================

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

0.1.3(10y ago)475.7k↓11.1%3[1 issues](https://github.com/BookingSync/oauth2-bookingsync-php/issues)MITPHPPHP &gt;=5.4.0CI failing

Since Jun 5Pushed 7y ago9 watchersCompare

[ Source](https://github.com/BookingSync/oauth2-bookingsync-php)[ Packagist](https://packagist.org/packages/bookingsync/oauth2-bookingsync-php)[ RSS](/packages/bookingsync-oauth2-bookingsync-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (5)Versions (5)Used By (0)

BookingSync Provider for OAuth 2.0 Client
=========================================

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

[![Latest Version](https://camo.githubusercontent.com/7746ef88fea95bd34aa40f70014536bbed318eb40315ae92a2ff4e73db9b9180/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f426f6f6b696e6753796e632f6f61757468322d626f6f6b696e6773796e632d7068702e7376673f7374796c653d666c61742d737175617265)](https://github.com/bookingsync/oauth2-bookingsync-php/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/42f7bc1b4022a6d0fa3a6e69ca989f063bc449fa5272792ba242a12b1a309721/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f426f6f6b696e6753796e632f6f61757468322d626f6f6b696e6773796e632d7068702f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/bookingsync/oauth2-bookingsync-php)[![Coverage Status](https://camo.githubusercontent.com/71e2bb5ae137d0d551f65ec7f7cb69030928f7a67a6c0ec4cd56c8825fdefe24/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f626f6f6b696e6773796e632f6f61757468322d626f6f6b696e6773796e632d7068702e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/bookingsync/oauth2-bookingsync-php/code-structure)[![Quality Score](https://camo.githubusercontent.com/acc5a6a0ee76b6f778aeb7ae926c182e4c3a5385f65655750307582913fc6ee5/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f626f6f6b696e6773796e632f6f61757468322d626f6f6b696e6773796e632d7068702e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/bookingsync/oauth2-bookingsync-php)[![Total Downloads](https://camo.githubusercontent.com/e4fe385a4615bb8c924e1b1a8c04b7f76d1ddd105545a2316ced3f5e6c242d9d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f626f6f6b696e6773796e632f6f61757468322d626f6f6b696e6773796e632d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bookingsync/oauth2-bookingsync-php)

This package provides BookingSync OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).

Deprecation warning
-------------------

[](#deprecation-warning)

This lib use old deprecated vendors. You may have an SSL certificate issue. To solve it, you should:

- Replace the cacert.pem file in the deprecated GuzzleHttp repo with an updated one from
- The location of the old pem file is `vendor/guzzle/guzzle/src/Guzzle/Http/Resources/cacert.pem`

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

[](#installation)

To install, use composer:

```
composer require bookingsync/oauth2-bookingsync-php

```

Usage
-----

[](#usage)

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

### Authorization Code Flow

[](#authorization-code-flow)

```
$provider = new Bookingsync\OAuth2\Client\Provider\Bookingsync([
    'clientId'          => 'XXXXXXXX',
    'clientSecret'      => 'XXXXXXXX',
    'redirectUri'       => 'https://www.example.com/callback-url', // https is mandatory for BookingSync
    'scopes'            => ['public'] // scopes required by your BookingSync application.
]);

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->screenName);

    } 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;

    // Use this to get a new access token if the old one expires
    echo $token->refreshToken;

    // Unix timestamp of when the token will expire, and need refreshing
    echo $token->expires;
}
```

### Refreshing a Token

[](#refreshing-a-token)

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

```
phpunit test

```

License
-------

[](#license)

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

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.9% 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 ~48 days

Total

4

Last Release

3856d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5bacfd70759b251d0f6a31cee0a339561709bb66a3a8aae7c035e599673a2069?d=identicon)[BookingSync](/maintainers/BookingSync)

---

Top Contributors

[![ZenCocoon](https://avatars.githubusercontent.com/u/10502?v=4)](https://github.com/ZenCocoon "ZenCocoon (8 commits)")[![JulienItard](https://avatars.githubusercontent.com/u/1370893?v=4)](https://github.com/JulienItard "JulienItard (1 commits)")

---

Tags

clientoauthoauth2authorizationauthorisationbookingsync

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/bookingsync-oauth2-bookingsync-php/health.svg)

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

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