PHPackages                             carsso/oauth2-ovhcloud - 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. carsso/oauth2-ovhcloud

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

carsso/oauth2-ovhcloud
======================

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

224PHP

Since Jan 30Pushed 4y ago1 watchersCompare

[ Source](https://github.com/carsso/oauth2-ovhcloud)[ Packagist](https://packagist.org/packages/carsso/oauth2-ovhcloud)[ RSS](/packages/carsso-oauth2-ovhcloud/feed)WikiDiscussions main Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

OVHcloud Provider for OAuth 2.0 Client
======================================

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

[![Source Code](https://camo.githubusercontent.com/657506aa5b913465d5f3dfdc6dce558c016ee41535355b2efb908ac5a9795051/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736f757263652d63617273736f2f6f61757468322d2d6f7668636c6f75642d626c75652e7376673f7374796c653d666c61742d737175617265)](https://github.com/carsso/oauth2-ovhcloud)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/carsso/oauth2-ovhcloud/blob/master/LICENSE)[![Build Status](https://camo.githubusercontent.com/bc3237044961a1f3bb9600191a3c6017e94500a2017b23eb6260cd6c7cf03ab7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f63617273736f2f6f61757468322d6f7668636c6f75642f43493f6c6162656c3d4349266c6f676f3d676974687562267374796c653d666c61742d737175617265)](https://github.com/carsso/oauth2-ovhcloud/actions?query=workflow%3ACI)[![Codecov Code Coverage](https://camo.githubusercontent.com/7f7d1ce2b7deb008e7bdd1fe048c461e39473357b492cb573db0450f8243c949/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f67682f63617273736f2f6f61757468322d6f7668636c6f75643f6c6162656c3d636f6465636f76266c6f676f3d636f6465636f76267374796c653d666c61742d737175617265)](https://codecov.io/gh/carsso/oauth2-ovhcloud)[![Total Downloads](https://camo.githubusercontent.com/544c22b10d46258f37715d236a158a3ff1678aead555402c9f413cc3f1a1479b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f63617273736f2f6f61757468322d6f7668636c6f75642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/carsso/oauth2-ovhcloud)

This package provides OVHcloud 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 carsso/oauth2-ovhcloud

```

Usage
-----

[](#usage)

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

### Authorization Code Flow

[](#authorization-code-flow)

```
$provider = new Carsso\OAuth2\Client\Provider\Ovhcloud([
    // See supported endpoints section below
    'endpoint'          => '{ovhcloud-endpoint}',
    // See OAuth2 application registration in supported endpoints section below
    'clientId'          => '{ovhcloud-client-id}',
    'clientSecret'      => '{ovhcloud-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
        printf('Hello %s (%s)!', $user->getName(), $user->getEmail());

    } catch (Exception $e) {

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

    // Use this to interact with an API on the user behalf (see OVHcloud API calls section below)
    echo $token->getToken();

    // Eventually refresh token if needed
    /*
    if ($token->hasExpired()) {
        $newAccessToken = $provider->getAccessToken('refresh_token', [
            'refresh_token' => $token->getRefreshToken()
        ]);
    }
    */
}
```

### Managing Scopes

[](#managing-scopes)

When creating your OVHcloud authorization URL, you can specify the state and scopes your application may authorize.

```
$options = [
    'state' => 'OPTIONAL_CUSTOM_CONFIGURED_STATE',
    'scope' => ['openid', 'profile', 'email', 'all'] // array or string
];

$authorizationUrl = $provider->getAuthorizationUrl($options);
```

Here are the default scopes the provider is using :

- openid
- profile
- email
- all

OVHcloud API calls
------------------

[](#ovhcloud-api-calls)

Since the OVHcloud API URL can vary, you can use the `getAuthenticatedApiRequest()` method of the provider (or `getApiRequest()` for unauthenticated calls).

```
$request = $provider->getAuthenticatedApiRequest(
    \Carsso\OAuth2\Client\Provider\Ovhcloud::METHOD_GET,
    '/me',
    $token
);
$response = $provider->getResponse($request);
```

Supported endpoints
-------------------

[](#supported-endpoints)

### OVH Europe

[](#ovh-europe)

`'endpoint' => 'ovh-eu',`

- API documentation:
- API console:
- API community support:
- OAuth2 application registration:

### OVH US

[](#ovh-us)

`'endpoint' => 'ovh-us',`

- API documentation:
- API console:
- OAuth2 application registration:

### OVH North America / Canada

[](#ovh-north-america--canada)

`'endpoint' => 'ovh-ca',`

- API documentation:
- API console:
- API community support:
- OAuth2 application registration:

Testing
-------

[](#testing)

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

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

[](#contributing)

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

Credits
-------

[](#credits)

- [Germain Carré](https://github.com/carsso)
- [All Contributors](https://github.com/carsso/oauth2-ovhcloud/contributors)

License
-------

[](#license)

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

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity27

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/1c285ff8fbcd7bd4710f53a68fffc4038215fbb579869dcf7482c3c85985caff?d=identicon)[carsso](/maintainers/carsso)

---

Top Contributors

[![carsso](https://avatars.githubusercontent.com/u/666182?v=4)](https://github.com/carsso "carsso (5 commits)")

### Embed Badge

![Health badge](/badges/carsso-oauth2-ovhcloud/health.svg)

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

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

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

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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