PHPackages                             gvarghese/oauth2-digitalocean - 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. gvarghese/oauth2-digitalocean

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

gvarghese/oauth2-digitalocean
=============================

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

v1.1(9y ago)019MITPHPPHP ^7.0

Since Feb 12Pushed 9y ago1 watchersCompare

[ Source](https://github.com/gregvarghese/oauth2-digitalocean)[ Packagist](https://packagist.org/packages/gvarghese/oauth2-digitalocean)[ RSS](/packages/gvarghese-oauth2-digitalocean/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (4)Versions (3)Used By (0)

DigitalOcean Provider for OAuth 2.0 Client
==========================================

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

This fork is of Chris Hemming's package is specifically only for PHP 7+ and the latest version of OAuth 2.0 client for compatibility with other OAuth 2.0 packages which require the newer version. I'll keep it updated with any changes from Chris Hemming's package.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#this-fork-is-of-chris-hemmings-package-is-specifically-only-for-php-7-and-the-latest-version-of-oauth-20-client-for-compatibility-with-other-oauth-20-packages-which-require-the-newer-version-ill-keep-it-updated-with-any-changes-from-chris-hemmings-package)

[![Latest Version](https://camo.githubusercontent.com/24e332218677f90a3a798e6f997a1a758c4f1b333acd901877d714964a7948b4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6776617267686573652f6f61757468322d6469676974616c6f6365616e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/gvarghese/oauth2-digitalocean/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://camo.githubusercontent.com/4413b703953d2633de999f9a4f2bf602dabef4bc46cd357ee7a01329e6934e03/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6776617267686573652f6f61757468322d6469676974616c6f6365616e2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/gvarghese/oauth2-digitalocean)[![Quality Score](https://camo.githubusercontent.com/b2e345f2ec5fd2e0b9d6e696690ea490f573ddd5c3d365dca8853fd57ce5d6a6/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6776617267686573652f6f61757468322d6469676974616c6f6365616e2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/gvarghese/oauth2-digitalocean)[![Total Downloads](https://camo.githubusercontent.com/99dd80df95d41d5163a4d57ad7392ba40d4731f8ddde7687cf438b100ad3126b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6776617267686573652f6f61757468322d6469676974616c6f6365616e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gvarghese/oauth2-digitalocean)

This package provides DigitalOcean 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 gregvarghese/oauth2-digitalocean

```

Usage
-----

[](#usage)

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

### Authorization Code Flow

[](#authorization-code-flow)

```
require_once('./vendor/autoload.php');
session_start();

$provider = new \ChrisHemmings\OAuth2\Client\Provider\DigitalOcean([
    'clientId'          => '{digitalocean-client-id}',
    'clientSecret'      => '{digitalocean-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/chrishemmings/oauth2-digitalocean/blob/master/CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Chris Hemmings](https://github.com/chrishemmings)
- [All Contributors](https://github.com/chrishemmings/oauth2-digitalocean/contributors)

License
-------

[](#license)

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

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75% 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 ~488 days

Total

2

Last Release

3302d ago

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

v1.1PHP ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4b8cb393997a07c8bdddca91a33ae0033e91f9f494c3a509b38c75888b483434?d=identicon)[gregv](/maintainers/gregv)

---

Top Contributors

[![gregvarghese](https://avatars.githubusercontent.com/u/12222172?v=4)](https://github.com/gregvarghese "gregvarghese (3 commits)")[![chrishemmings](https://avatars.githubusercontent.com/u/7426965?v=4)](https://github.com/chrishemmings "chrishemmings (1 commits)")

---

Tags

AuthenticationSSOidentityoauthoauth2authorizationidpsingle sign ondigitalocean

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/gvarghese-oauth2-digitalocean/health.svg)

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

###  Alternatives

[calcinai/oauth2-xero

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

103.4M4](/packages/calcinai-oauth2-xero)[adam-paterson/oauth2-slack

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

22749.0k9](/packages/adam-paterson-oauth2-slack)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
