PHPackages                             julienbornstein/oauth2-deezer - 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. julienbornstein/oauth2-deezer

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

julienbornstein/oauth2-deezer
=============================

Deezer Oauth 2.0 Client Provider for The PHP League OAuth2-Client

0.1.7(1y ago)17.8k↓50%[2 PRs](https://github.com/julienbornstein/oauth2-deezer/pulls)MITPHPPHP &gt;=7.3.0CI passing

Since Nov 2Pushed 3mo ago1 watchersCompare

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

READMEChangelogDependencies (14)Versions (10)Used By (0)

[![PHP version](https://camo.githubusercontent.com/a0c355dbae93c91c6682dd585c40872fca7c4b91285b36e8d3e99d7874952963/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230372e312d3838393242462e7376673f7374796c653d666f722d7468652d6261646765)](https://php.net)[![GitHub Workflow Status](https://camo.githubusercontent.com/f77498590c5bc3a67126b3cbf40e609cfc18d6653ff667f109dcfb1cfae9b329/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6a756c69656e626f726e737465696e2f6f61757468322d6465657a65722f436f6e74696e756f7573253230496e746567726174696f6e3f7374796c653d666f722d7468652d6261646765)](https://github.com/julienbornstein/oauth2-deezer/actions/workflows/continuous-integration.yml)[![Codecov](https://camo.githubusercontent.com/acec43cb765bb9667a37c64deb5cb06e7e48a39a8bd98442d60830ff5b0312be/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6a756c69656e626f726e737465696e2f6f61757468322d6465657a65723f7374796c653d666f722d7468652d6261646765)](https://app.codecov.io/gh/julienbornstein/oauth2-deezer)[![Total Downloads](https://camo.githubusercontent.com/b474a0b5786da44a44616c5b8bc40f971a419e2a30ffa227bac6e98bfd81ad7d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a756c69656e626f726e737465696e2f6f61757468322d6465657a65722e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/julienbornstein/oauth2-deezer)[![Latest Stable Version](https://camo.githubusercontent.com/dfa15d29d386145a2b9d9208f52df6a52319a14fc3cb6e2cb9ba8c43a9197139/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a756c69656e626f726e737465696e2f6f61757468322d6465657a65722e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/julienbornstein/oauth2-deezer)[![License](https://camo.githubusercontent.com/98a8be6d082e4f64f72738271dba7b90baecf2cefec12b060cb11ad558bbf41e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a756c69656e626f726e737465696e2f6f61757468322d6465657a65722e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/julienbornstein/oauth2-deezer)

Deezer Provider for OAuth 2.0 Client
====================================

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

This package provides Deezer 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 julienbornstein/oauth2-deezer

```

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 `\ParisBouge\OAuth2\Client\Provider\Deezer` as the provider.

### Authorization Code Flow

[](#authorization-code-flow)

```
$provider = new ParisBouge\OAuth2\Client\Provider\Deezer([
    'clientId'     => '{deezer-client-id}',
    'clientSecret' => '{deezer-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' => [
            ParisBouge\OAuth2\Client\Provider\Deezer::SCOPE_BASIC_ACCESS,
            ParisBouge\OAuth2\Client\Provider\Deezer::SCOPE_EMAIL,
        ]
    ]);

    $_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 \ParisBouge\OAuth2\Client\Provider\DeezerResourceOwner $user */
    $user = $provider->getResourceOwner($token);

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

    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)

The following scopes are available as described in the [official documentation](https://developers.deezer.com/api/permissions):

- SCOPE\_BASIC\_ACCESS
- SCOPE\_EMAIL
- SCOPE\_OFFLINE\_ACCESS
- SCOPE\_MANAGE\_LIBRARY
- SCOPE\_MANAGE\_COMMUNITY
- SCOPE\_DELETE\_LIBRARY
- SCOPE\_LISTENING\_HISTORY

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

[](#contributing)

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

Credits
-------

[](#credits)

- [Julien Bornstein](https://github.com/julienbornstein)

License
-------

[](#license)

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

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance64

Regular maintenance activity

Popularity25

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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

Recently: every ~344 days

Total

7

Last Release

444d ago

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

0.1.6PHP &gt;=7.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/274dfb5d01b6a08bdfca95bc73fbcd07844747b24f8fda98fcef3304e66d0d05?d=identicon)[julienbornstein](/maintainers/julienbornstein)

---

Top Contributors

[![julienbornstein](https://avatars.githubusercontent.com/u/548449?v=4)](https://github.com/julienbornstein "julienbornstein (9 commits)")

---

Tags

clientAuthenticationoauthoauth2authorizationDeezer

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/julienbornstein-oauth2-deezer/health.svg)

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

###  Alternatives

[league/oauth2-google

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

42121.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)

PHPackages © 2026

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