Skip to content
docsv0.1.0

TwitchOAuthService

Twitch OAuth 2.0 protocol implementation. Uses the Twitch Helix API for user info retrieval. Note: Twitch requires the Client-Id header alongside the Bearer token when calling the Helix API.

TwitchOAuthService::__construct()

public function __construct(string $clientId, string $clientSecret):

Parameters

Parameters of __construct()
NameTypeDescription
$clientIdstring
$clientSecretstring

TwitchOAuthService::getAuthUrl()

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

Build the Twitch authorization URL requesting the user:read:email scope.

Parameters

Parameters of getAuthUrl()
NameTypeDescription
$redirectUristring
$state?string

TwitchOAuthService::exchangeCode()

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

Exchange the authorization code for an access token, then fetch the profile from the Twitch Helix API.

Parameters

Parameters of exchangeCode()
NameTypeDescription
$codestring
$redirectUristring