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

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

chrishemmings/oauth2-digitalocean
=================================

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

2.0.2(6y ago)75.6k↓41.7%6MITPHPCI failing

Since Feb 12Pushed 6y ago1 watchersCompare

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

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

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

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

[![Latest Version](https://camo.githubusercontent.com/877119f7433e5a1a25d9cdfb38dda1d21a66bea7ad50e48261289dd6e20b8f73/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f636872697368656d6d696e67732f6f61757468322d6469676974616c6f6365616e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/chrishemmings/oauth2-digitalocean/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://camo.githubusercontent.com/3bed749f42c3027033f5fd04020883305d2e65a470d84de8623772290a73ab4b/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f636872697368656d6d696e67732f6f61757468322d6469676974616c6f6365616e2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/chrishemmings/oauth2-digitalocean)[![Quality Score](https://camo.githubusercontent.com/506015ca75416b724659c4a9aede96f512a8461eb7eca6445cff028f2ad49bea/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f636872697368656d6d696e67732f6f61757468322d6469676974616c6f6365616e2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/chrishemmings/oauth2-digitalocean)[![Total Downloads](https://camo.githubusercontent.com/b4b4a2ed68fead9cb44f00f4a6e5abd607cde1283a1bc247ac1b49c21374aed8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636872697368656d6d696e67732f6f61757468322d6469676974616c6f6365616e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/chrishemmings/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 chrishemmings/oauth2-digitalocean

```

Usage
-----

[](#usage)

Usage is the same as The League's OAuth client, using `\ChrisHemmings\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)
- [Daniel Hensby](https://github.com/dhensby)
- [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

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% 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 ~509 days

Total

4

Last Release

2221d ago

Major Versions

1.0.0 → 2.0.02017-07-10

### Community

Maintainers

![](https://www.gravatar.com/avatar/8639948042c5affb0d40f2062b692b11ef04659c7d86d4a47ca9b0e7243e3bd6?d=identicon)[chrishemmings](/maintainers/chrishemmings)

---

Top Contributors

[![chrishemmings](https://avatars.githubusercontent.com/u/7426965?v=4)](https://github.com/chrishemmings "chrishemmings (12 commits)")[![dhensby](https://avatars.githubusercontent.com/u/563596?v=4)](https://github.com/dhensby "dhensby (6 commits)")

---

Tags

digitaloceanoauth2php-leagueAuthenticationSSOidentityoauthoauth2authorizationidpsingle sign ondigitalocean

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[adam-paterson/oauth2-slack

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

22694.8k5](/packages/adam-paterson-oauth2-slack)

PHPackages © 2026

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