friendship ended with social-app. php is my new best friend
1<?php 2/** 3 * Class Tumblr2 4 * 5 * @created 30.07.2023 6 * @author smiley <smiley@chillerlan.net> 7 * @copyright 2023 smiley 8 * @license MIT 9 */ 10declare(strict_types=1); 11 12namespace chillerlan\OAuth\Providers; 13 14use chillerlan\OAuth\Core\{ 15 AuthenticatedUser, ClientCredentials, ClientCredentialsTrait, CSRFToken, OAuth2Provider, TokenRefresh, UserInfo, 16}; 17use function sprintf; 18 19/** 20 * Tumblr OAuth2 21 * 22 * @link https://www.tumblr.com/docs/en/api/v2#oauth2-authorization 23 */ 24class Tumblr2 extends OAuth2Provider implements CSRFToken, TokenRefresh, ClientCredentials, UserInfo{ 25 use ClientCredentialsTrait; 26 27 public const IDENTIFIER = 'TUMBLR2'; 28 29 public const SCOPE_BASIC = 'basic'; 30 public const SCOPE_WRITE = 'write'; 31 public const SCOPE_OFFLINE_ACCESS = 'offline_access'; 32 33 public const DEFAULT_SCOPES = [ 34 self::SCOPE_BASIC, 35 self::SCOPE_WRITE, 36 self::SCOPE_OFFLINE_ACCESS, 37 ]; 38 39 protected string $authorizationURL = 'https://www.tumblr.com/oauth2/authorize'; 40 protected string $accessTokenURL = 'https://api.tumblr.com/v2/oauth2/token'; 41 protected string $apiURL = 'https://api.tumblr.com'; 42 protected string|null $userRevokeURL = 'https://www.tumblr.com/settings/apps'; 43 protected string|null $apiDocs = 'https://www.tumblr.com/docs/en/api/v2'; 44 protected string|null $applicationURL = 'https://www.tumblr.com/oauth/apps'; 45 46 /** @codeCoverageIgnore */ 47 public function me():AuthenticatedUser{ 48 $json = $this->getMeResponseData('/v2/user/info'); 49 50 $userdata = [ 51 'data' => $json, 52 'handle' => $json['response']['user']['name'], 53 'url' => sprintf('https://www.tumblr.com/%s', $json['response']['user']['name']), 54 ]; 55 56 return new AuthenticatedUser($userdata); 57 } 58 59}