PHPackages                             itsmestevieg/oauth2-nitrado - 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. itsmestevieg/oauth2-nitrado

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

itsmestevieg/oauth2-nitrado
===========================

Nitrado OAuth 2.0 support for the PHP League's OAuth 2.0 Client

1.0.1(5y ago)21.2k1[2 issues](https://github.com/ItsMeStevieG/oauth2-nitrado/issues)MITPHPPHP &gt;=7.3

Since Feb 16Pushed 5y ago1 watchersCompare

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

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

 [ ![Gitter](https://camo.githubusercontent.com/0f0c5954db8ced383dbc7c6ee283dc47a824228ccf8be0b5b0e0d1684e45c2a3/68747470733a2f2f696d672e736869656c64732e696f2f6769747465722f726f6f6d2f6974736d65737465766965672f61757468322d6e69747261646f3f7374796c653d666f722d7468652d6261646765) ](https://gitter.im/oauth2-nitrado/community "Repo Chat") [ ![PHP Version](https://camo.githubusercontent.com/f2c089bfeca86135ecc6da9f93a10546af3e877d6f27f197d998a9bccc83484e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230372e332d3838393242462e7376673f7374796c653d666f722d7468652d6261646765) ](https://php.net "PHP Version") [ ![Downloads](https://camo.githubusercontent.com/3434c2c68fa085179b26164d7d32f5cd0fe161f93ddca392000553db0b3c1a8c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6974736d65737465766965672f6f61757468322d6e69747261646f2e7376673f7374796c653d666f722d7468652d6261646765) ](https://packagist.org/packages/itsmestevieg/oauth2-nitrado "Downloads") [ ![Latest Stable Version](https://camo.githubusercontent.com/0d724b738db64ffdbaad54d20ded0ce35641fb2f53f9594d24e9a48ce49e39cc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6974736d65737465766965672f6f61757468322d6e69747261646f2e7376673f7374796c653d666f722d7468652d6261646765) ](https://packagist.org/packages/itsmestevieg/oauth2-nitrado "Latest Stable Version") [ ![License](https://camo.githubusercontent.com/e981ba569e59348070406498357a340f6416e8f61d76a506235e18eee246d992/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6974736d65737465766965672f6f61757468322d6e69747261646f2e7376673f7374796c653d666f722d7468652d6261646765) ](https://packagist.org/packages/itsmestevieg/oauth2-nitrado "License")

Nitrado Provider for OAuth 2.0 Client
=====================================

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

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

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

[](#installation)

You can install this package using Composer:

```
composer require itsmestevieg/oauth2-nitrado

```

You will then need to:

- run `composer install` to get these dependencies added to your vendor directory
- add the autoloader to your application with this line: `require('vendor/autoload.php');`

Usage
-----

[](#usage)

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

### Authorization Code Flow

[](#authorization-code-flow)

```
$provider = new ItsMeStevieG\OAuth2\Client\Provider\Nitrado([
    'clientId'     => '{nitrado-client-id}',
    'clientSecret' => '{nitrado-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([
        'scope' => [
            ItsMeStevieG\OAuth2\Client\Provider\Nitrado::SCOPE_USER_INFO,
        ]
    ]);

    $_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']);
    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 user's details
    /** @var \ItsMeStevieG\OAuth2\Client\Provider\NitradoResourceOwner $user */
    $user = $provider->getResourceOwner($token);

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

    echo '';
    var_dump($user);
    echo '';

} catch (Exception $e) {

    // Failed to get user details
    exit('Damned...');
}

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

// The time (in epoch time) when an access token will expire
var_dump($token->getExpires());
# int(1436825866)
echo '';
```

### Authorization Scopes

[](#authorization-scopes)

All scopes described in the [official documentation](https://doc.nitrado.net/#api-OAuth_2-CreateAuthToken) are available through public constants in `\ItsMeStevieG\OAuth2\Client\Provider\Nitrado`:

- SCOPE\_USER\_INFO
- SCOPE\_SERVICE
- SCOPE\_SERVICE\_ORDER
- SCOPE\_SSH\_KEYS

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

[](#contributing)

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

Credits
-------

[](#credits)

- [Steven Graham](https://github.com/ItsMeStevieG)

License
-------

[](#license)

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

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community8

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

Every ~0 days

Total

2

Last Release

1910d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/40be279192e41e3db50404bf1f0f18dc8dfbb9b52d0e8320cab4df2b670e3128?d=identicon)[ItsMeStevieG](/maintainers/ItsMeStevieG)

---

Top Contributors

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

---

Tags

phpclientAuthenticationoauthoauth2authorizationnitrado

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/itsmestevieg-oauth2-nitrado/health.svg)

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

###  Alternatives

[league/oauth2-google

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

41721.2M118](/packages/league-oauth2-google)[cakedc/oauth2-cognito

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

18597.7k](/packages/cakedc-oauth2-cognito)[andalisolutions/oauth2-anaf

Anaf OAuth 2.0 support for the PHP League's OAuth 2.0 Client

194.1k](/packages/andalisolutions-oauth2-anaf)

PHPackages © 2026

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