PHPackages                             geekdevs/oauth2-cronofy - 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. geekdevs/oauth2-cronofy

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

geekdevs/oauth2-cronofy
=======================

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

2.0.2(6y ago)315.3kMITPHPPHP ^7.4CI failing

Since Mar 23Pushed 5y ago2 watchersCompare

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

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

Cronofy Provider for OAuth 2.0 Client
=====================================

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

[![Build Status](https://camo.githubusercontent.com/ec52c8cbd7006fdebd181ddef2b9cabbfc668e3731ce1bf17a83c5149d3d559e/68747470733a2f2f7472617669732d63692e6f72672f6765656b646576732f6f61757468322d63726f6e6f66792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/geekdevs/oauth2-cronofy)[![Latest Stable Version](https://camo.githubusercontent.com/4d5e188da31f2d56927164c4453f1ac9e11252511a45bf6408cf80c3d02bbd89/68747470733a2f2f706f7365722e707567782e6f72672f6765656b646576732f6f61757468322d63726f6e6f66792f762f737461626c65)](https://packagist.org/packages/geekdevs/oauth2-cronofy)

This package provides [Cronofy Calendar](https://www.cronofy.com/developers/api/) OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).

This package is compliant with [PSR-1](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md), [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md), [PSR-4](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md), and [PSR-7](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-7-http-message.md). If you notice compliance oversights, please send a patch via pull request.

Requirements
------------

[](#requirements)

The following versions of PHP are supported.

- PHP 7.4

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

[](#installation)

Add the following to your `composer.json` file.

```
{
    "require": {
        "geekdevs/oauth2-cronofy": "^2.0"
    }
}
```

Usage
-----

[](#usage)

### Authorization Code Flow

[](#authorization-code-flow)

```
session_start();

$provider = new Geekdevs\OAuth2\Client\Provider\Cronofy([
    'clientId'          => '{cronofy-app-id}',
    'clientSecret'      => '{cronofy-app-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([
        'scope' => ['read_account', '...', '...'],
    ]);
    $_SESSION['oauth2state'] = $provider->getState();

    echo 'Log in with Cronofy!';
    exit;

// Check given state against previously stored one to mitigate CSRF attack
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {

    unset($_SESSION['oauth2state']);
    echo 'Invalid state.';
    exit;

}

// 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 account's details
    $account = $provider->getResourceOwner($token);

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

    echo '';
    var_dump($account);
    # object(League\OAuth2\Client\Provider\CronofyAccount)#10 (1) { ...
    echo '';

} catch (Exception $e) {

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

echo '';
// Use this to interact with an API on the users behalf
var_dump($token->getToken());
# string(217) "CAADAppfn3msBAI7tZBLWg...

// Number of seconds until the access token will expire, and need refreshing
var_dump($token->getExpires());
# int(1436825866)
echo '';
```

### The CronofyAccount Entity

[](#the-cronofyaccount-entity)

When using the `getResourceOwner()` method to obtain the account details, it will be returned as a `CronofyAccount` entity.

```
$account = $provider->getResourceOwner($token);

$id = $account->getId();
var_dump($id);
# string(1) "acc_567236000909002"

$name = $account->getName();
var_dump($name);
# string(15) "Pavel Dubinin"

$email = $account->getEmail();
var_dump($email);
# string(15) "geekevs@gmail.com"

$timezone = $account->getDefaultTimezone();
var_dump($timezone);
# string(15) "Europe/London"
```

You can also get all the data from the Account node as a plain-old PHP array with `toArray()`.

```
$accountData = $account->toArray();
```

Testing
-------

[](#testing)

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

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

[](#contributing)

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

Credits
-------

[](#credits)

- [Pavel Dubinin](https://github.com/geekdevs)
- [All Contributors](https://github.com/geekdevs/oauth2-cronofy/contributors)

License
-------

[](#license)

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

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity71

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

Recently: every ~123 days

Total

15

Last Release

2233d ago

Major Versions

0.3.0 → 1.0.02016-09-12

1.1.6 → 2.0.02020-04-06

PHP version history (2 changes)0.1.0PHP &gt;=5.5.0

2.0.0PHP ^7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c32f742614130f40944df419b067a2d308175dfcc1ea2ced80a37885585aa53?d=identicon)[geekdevs](/maintainers/geekdevs)

---

Top Contributors

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

---

Tags

clientAuthenticationoauthoauth2authorizationcalendarcronofy

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/geekdevs-oauth2-cronofy/health.svg)

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

###  Alternatives

[league/oauth2-google

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

42121.2M118](/packages/league-oauth2-google)[cronofy/cronofy

SDK for Cronofy - the Scheduling Platform for Business

21778.5k](/packages/cronofy-cronofy)[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)
