friendship ended with social-app. php is my new best friend
1<?php 2/** 3 * Class TwitterCC 4 * 5 * @created 08.04.2018 6 * @author Smiley <smiley@chillerlan.net> 7 * @copyright 2018 Smiley 8 * @license MIT 9 */ 10declare(strict_types=1); 11 12namespace chillerlan\OAuth\Providers; 13 14use chillerlan\OAuth\Core\{AccessToken, ClientCredentials, ClientCredentialsTrait, OAuth2Provider}; 15use Psr\Http\Message\UriInterface; 16 17/** 18 * Twitter OAuth2 (client credentials) 19 * 20 * @todo: twitter is dead. fuck elon musk. 21 * 22 * @link https://dev.twitter.com/overview/api 23 * @link https://developer.twitter.com/en/docs/basics/authentication/overview/application-only 24 * 25 * @todo: https://developer.twitter.com/en/docs/basics/authentication/api-reference/invalidate_token 26 */ 27class TwitterCC extends OAuth2Provider implements ClientCredentials{ 28 use ClientCredentialsTrait; 29 30 public const IDENTIFIER = 'TWITTERCC'; 31 32 protected const AUTH_ERRMSG = 'TwitterCC only supports Client Credentials Grant,'. 33 'use the Twitter OAuth1 class for authentication instead.'; 34 35 protected string $apiURL = 'https://api.twitter.com'; 36 protected string|null $clientCredentialsTokenURL = 'https://api.twitter.com/oauth2/token'; 37 protected string|null $userRevokeURL = 'https://twitter.com/settings/applications'; 38 // phpcs:ignore 39 protected string|null $apiDocs = 'https://developer.twitter.com/en/docs/basics/authentication/overview/application-only'; 40 protected string|null $applicationURL = 'https://developer.twitter.com/apps'; 41 42 /** 43 * @throws \chillerlan\OAuth\Providers\ProviderException 44 */ 45 public function getAuthorizationURL(array|null $params = null, array|null $scopes = null):UriInterface{ 46 throw new ProviderException($this::AUTH_ERRMSG); 47 } 48 49 /** 50 * @throws \chillerlan\OAuth\Providers\ProviderException 51 */ 52 public function getAccessToken(string $code, string|null $state = null):AccessToken{ 53 throw new ProviderException($this::AUTH_ERRMSG); 54 } 55 56}