friendship ended with social-app. php is my new best friend
1<?php 2/** 3 * Class SoundCloud 4 * 5 * @created 22.10.2017 6 * @author Smiley <smiley@chillerlan.net> 7 * @copyright 2017 Smiley 8 * @license MIT 9 */ 10declare(strict_types=1); 11 12namespace chillerlan\OAuth\Providers; 13 14use chillerlan\OAuth\Core\{AuthenticatedUser, ClientCredentials, ClientCredentialsTrait, OAuth2Provider, TokenRefresh, UserInfo}; 15 16/** 17 * SoundCloud OAuth2 18 * 19 * @link https://developers.soundcloud.com/ 20 * @link https://developers.soundcloud.com/docs/api/guide#authentication 21 * @link https://developers.soundcloud.com/blog/security-updates-api 22 */ 23class SoundCloud extends OAuth2Provider implements ClientCredentials, TokenRefresh, UserInfo{ 24 use ClientCredentialsTrait; 25 26 public const IDENTIFIER = 'SOUNDCLOUD'; 27 28 public const SCOPE_NONEXPIRING = 'non-expiring'; 29# public const SCOPE_EMAIL = 'email'; // ??? 30 31 public const DEFAULT_SCOPES = [ 32 self::SCOPE_NONEXPIRING, 33 ]; 34 35 public const AUTH_PREFIX_HEADER = 'OAuth'; 36 37 protected string $authorizationURL = 'https://api.soundcloud.com/connect'; 38 protected string $accessTokenURL = 'https://api.soundcloud.com/oauth2/token'; 39 protected string $apiURL = 'https://api.soundcloud.com'; 40 protected string|null $userRevokeURL = 'https://soundcloud.com/settings/connections'; 41 protected string|null $apiDocs = 'https://developers.soundcloud.com/'; 42 protected string|null $applicationURL = 'https://soundcloud.com/you/apps'; 43 44 /** @codeCoverageIgnore */ 45 public function me():AuthenticatedUser{ 46 $json = $this->getMeResponseData('/me'); 47 48 $userdata = [ 49 'data' => $json, 50 'avatar' => $json['avatar_url'], 51 'handle' => $json['username'], 52 'displayName' => $json['full_name'], 53 'email' => $json['email'], 54 'id' => $json['id'], 55 'url' => $json['permalink_url'], 56 ]; 57 58 return new AuthenticatedUser($userdata); 59 } 60 61}