PHPackages                             martin1982/oauth2-soundcloud - 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. martin1982/oauth2-soundcloud

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

martin1982/oauth2-soundcloud
============================

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

2.0.0(3y ago)13.6k↑100%MITPHPPHP &gt;=8.0

Since Aug 9Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Martin1982/oauth2-soundcloud)[ Packagist](https://packagist.org/packages/martin1982/oauth2-soundcloud)[ Docs](https://github.com/Martin1982/oauth2-soundcloud)[ RSS](/packages/martin1982-oauth2-soundcloud/feed)WikiDiscussions main Synced 1mo ago

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

[![PHP version](https://camo.githubusercontent.com/6fb2a748280f4babda722f3fc10fba40d1d744bab448352683a0188654ce1ec7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230372e342d3838393242462e7376673f7374796c653d666f722d7468652d6261646765)](https://php.net)[![GitHub Workflow Status](https://camo.githubusercontent.com/30180b84443b1123d744de0a209e0f0c54d20a2d70c26fff3052f5504c96e56d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6d617274696e313938322f6f61757468322d736f756e64636c6f75642f436f6e74696e756f7573253230496e746567726174696f6e3f7374796c653d666f722d7468652d6261646765)](https://github.com/martin1982/oauth2-soundcloud/actions/workflows/continuous-integration.yml)[![Total Downloads](https://camo.githubusercontent.com/d893be213725b506801ff570a1fcc7599ccea25692871e472bbeb113c394a8b6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d617274696e313938322f6f61757468322d736f756e64636c6f75642e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/martin1982/oauth2-soundcloud)[![Latest Stable Version](https://camo.githubusercontent.com/70af2aeca14a6645d18ec2d4bfe9c7a65bc588d635bb7684e0a902d53b70d10f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d617274696e313938322f6f61757468322d736f756e64636c6f75642e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/martin1982/oauth2-soundcloud)

SoundCloud Provider for OAuth 2.0 Client
========================================

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

This package provides SoundCloud 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 martin1982/oauth2-soundcloud

```

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

### Authorization Code Flow

[](#authorization-code-flow)

```
$provider = new Martin1982\OAuth2\Client\Provider\SoundCloud([
    'clientId'     => '{soundcloud-client-id}',
    'clientSecret' => '{soundcloud-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']);
    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 \Martin1982\OAuth2\Client\Provider\SoundCloudResourceOwner $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 '';
```

Credits
-------

[](#credits)

- Based on oauth2-deezer by [Julien Bornstein](https://github.com/julienbornstein)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/martin1982/oauth2-soundcloud/blob/main/LICENSE) for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

Total

2

Last Release

1257d ago

Major Versions

1.0.0 → 2.0.02022-12-09

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

2.0.0PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/159f8a8c2464c072af98424168596d4fa5b303356afbdff906e91b6ec744dc00?d=identicon)[Martin1982](/maintainers/Martin1982)

---

Top Contributors

[![Martin1982](https://avatars.githubusercontent.com/u/408395?v=4)](https://github.com/Martin1982 "Martin1982 (1 commits)")

---

Tags

clientAuthenticationoauthoauth2authorizationsoundcloud

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/martin1982-oauth2-soundcloud/health.svg)

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

###  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)
