Skip to content
docsv0.1.0

TwitchOAuthServiceInterface

Contract for Twitch OAuth operations. Each consumer plugin provides its own redirectUri to support independent callback routes per plugin.

TwitchOAuthServiceInterface::getAuthUrl()

abstract public function getAuthUrl(string $redirectUri, ?string $state = null): string

Build the Twitch authorization URL.

Parameters

Parameters of getAuthUrl()
NameTypeDescription
$redirectUristringCallback URL specific to the consumer plugin
$state(string | null)Opaque CSRF-protection value. When given, it is appended to the URL as-is and Twitch echoes it back unmodified on the query string of the callback request. Generating, storing, and verifying it is entirely the caller's responsibility — this provider only transports it.

TwitchOAuthServiceInterface::exchangeCode()

abstract public function exchangeCode(string $code, string $redirectUri): Milpa\OAuth\DTO\TwitchUserInfo

Exchange authorization code for user info.

Parameters

Parameters of exchangeCode()
NameTypeDescription
$codestringAuthorization code from Twitch callback
$redirectUristringMust match the one used in getAuthUrl()