{"id":37265723,"url":"https://github.com/ker0x/oauth2-spotify","last_synced_at":"2026-01-16T00:11:57.508Z","repository":{"id":48285991,"uuid":"156765231","full_name":"ker0x/oauth2-spotify","owner":"ker0x","description":"🎶 Spotify OAuth 2.0 Client Provider for The PHP League OAuth2-Client","archived":false,"fork":false,"pushed_at":"2023-02-07T10:52:56.000Z","size":51,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-14T15:48:48.961Z","etag":null,"topics":["oauth","oauth2","oauth2-provider","php","php-league","spotify"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ker0x.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-08T20:32:39.000Z","updated_at":"2025-02-16T23:51:45.000Z","dependencies_parsed_at":"2023-01-23T11:16:00.543Z","dependency_job_id":null,"html_url":"https://github.com/ker0x/oauth2-spotify","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/ker0x/oauth2-spotify","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ker0x%2Foauth2-spotify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ker0x%2Foauth2-spotify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ker0x%2Foauth2-spotify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ker0x%2Foauth2-spotify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ker0x","download_url":"https://codeload.github.com/ker0x/oauth2-spotify/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ker0x%2Foauth2-spotify/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28474407,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T00:03:33.697Z","status":"ssl_error","status_checked_at":"2026-01-15T23:58:36.859Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["oauth","oauth2","oauth2-provider","php","php-league","spotify"],"created_at":"2026-01-16T00:11:56.880Z","updated_at":"2026-01-16T00:11:57.503Z","avatar_url":"https://github.com/ker0x.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n    \u003ca href=\"https://github.com/ker0x/oauth2-spotify/actions/workflows/ci.yml\" title=\"Build\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/ker0x/oauth2-spotify/ci.yml?branch=main\u0026style=for-the-badge\" alt=\"Build\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://scrutinizer-ci.com/g/ker0x/oauth2-spotify/\" title=\"Coverage\"\u003e\n        \u003cimg src=\"https://img.shields.io/codecov/c/gh/ker0x/oauth2-spotify?style=for-the-badge\" alt=\"Coverage\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://php.net\" title=\"PHP Version\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/php-%3E%3D%208.1-8892BF.svg?style=for-the-badge\" alt=\"PHP Version\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/kerox/oauth2-spotify\" title=\"Downloads\"\u003e\n        \u003cimg src=\"https://img.shields.io/packagist/dt/kerox/oauth2-spotify.svg?style=for-the-badge\" alt=\"Downloads\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/kerox/oauth2-spotify\" title=\"Latest Stable Version\"\u003e\n        \u003cimg src=\"https://img.shields.io/packagist/v/kerox/oauth2-spotify.svg?style=for-the-badge\" alt=\"Latest Stable Version\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/kerox/oauth2-spotify\" title=\"License\"\u003e\n        \u003cimg src=\"https://img.shields.io/packagist/l/kerox/oauth2-spotify.svg?style=for-the-badge\" alt=\"License\"\u003e\n    \u003c/a\u003e\n\u003c/div\u003e\n\n# Spotify Provider for OAuth 2.0 Client\n\nThis package provides Spotify OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).\n\n## Installation\n\nYou can install this package using Composer:\n\n```\ncomposer require kerox/oauth2-spotify\n```\n\nYou will then need to:\n* run ``composer install`` to get these dependencies added to your vendor directory\n* add the autoloader to your application with this line: ``require('vendor/autoload.php');``\n\n## Usage\n\nUsage is the same as The League's OAuth client, using `\\Kerox\\OAuth2\\Client\\Provider\\Spotify` as the provider.\n\n### Authorization Code Flow\n\n```php\n$provider = new Kerox\\OAuth2\\Client\\Provider\\Spotify([\n    'clientId'     =\u003e '{spotify-client-id}',\n    'clientSecret' =\u003e '{spotify-client-secret}',\n    'redirectUri'  =\u003e 'https://example.com/callback-url',\n]);\n\nif (!isset($_GET['code'])) {\n    // If we don't have an authorization code then get one\n    $authUrl = $provider-\u003egetAuthorizationUrl([\n        'scope' =\u003e [\n            Kerox\\OAuth2\\Client\\Provider\\SpotifyScope::USER_READ_EMAIL-\u003evalue,\n        ]\n    ]);\n    \n    $_SESSION['oauth2state'] = $provider-\u003egetState();\n    \n    header('Location: ' . $authUrl);\n    exit;\n\n// Check given state against previously stored one to mitigate CSRF attack\n} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {\n\n    unset($_SESSION['oauth2state']);\n    echo 'Invalid state.';\n    exit;\n\n}\n\n// Try to get an access token (using the authorization code grant)\n$token = $provider-\u003egetAccessToken('authorization_code', [\n    'code' =\u003e $_GET['code']\n]);\n\n// Optional: Now you have a token you can look up a users profile data\ntry {\n\n    // We got an access token, let's now get the user's details\n    /** @var \\Kerox\\OAuth2\\Client\\Provider\\SpotifyResourceOwner $user */\n    $user = $provider-\u003egetResourceOwner($token);\n\n    // Use these details to create a new profile\n    printf('Hello %s!', $user-\u003egetDisplayName());\n    \n    echo '\u003cpre\u003e';\n    var_dump($user);\n    echo '\u003c/pre\u003e';\n\n} catch (Exception $e) {\n\n    // Failed to get user details\n    exit('Damned...');\n}\n\necho '\u003cpre\u003e';\n// Use this to interact with an API on the users behalf\nvar_dump($token-\u003egetRefreshToken());\n# string(217) \"CAADAppfn3msBAI7tZBLWg...\n\n// The time (in epoch time) when an access token will expire\nvar_dump($token-\u003egetExpires());\n# int(1436825866)\necho '\u003c/pre\u003e';\n```\n\n### Authorization Scopes\n\nAll scopes described in the [official documentation](https://developer.spotify.com/documentation/general/guides/authorization/scopes/) are available through the `\\Kerox\\OAuth2\\Client\\Provider\\SpotifyScope` enumeration:\n\n- Images\n  * UGC_IMAGE_UPLOAD\n- Spotify Connect \n  * USER_READ_PLAYBACK_STATE\n  * USER_MODIFY_PLAYBACK_STATE\n  * USER_READ_CURRENTLY_PLAYING\n- Playback\n  * APP_REMOTE_CONTROL\n  * STREAMING\n- Playlists\n  * PLAYLIST_READ_PRIVATE\n  * PLAYLIST_READ_COLLABORATIVE\n  * PLAYLIST_MODIFY_PRIVATE\n  * PLAYLIST_MODIFY_PUBLIC\n- Follow\n  * USER_FOLLOW_MODIFY\n  * USER_FOLLOW_READ\n- Listening History\n  * USER_READ_PLAYBACK_POSITION\n  * USER_TOP_READ\n  * USER_READ_RECENTLY_PLAYED\n- Library\n  * USER_LIBRARY_MODIFY\n  * USER_LIBRARY_READ\n- Users\n  * USER_READ_PRIVATE\n  * USER_READ_EMAIL\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/ker0x/oauth2-spotify/blob/master/CONTRIBUTING.md) for details.\n\n## Credits\n\n- [Romain Monteil](https://github.com/ker0x)\n\n## License\n\nThe MIT License (MIT). Please see [License File](https://github.com/ker0x/oauth2-spotify/blob/master/LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fker0x%2Foauth2-spotify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fker0x%2Foauth2-spotify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fker0x%2Foauth2-spotify/lists"}