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
| Name | Type | Description |
|---|---|---|
| $clientId | string | |
| $clientSecret | string |
TwitchOAuthService::getAuthUrl()
public function getAuthUrl(string $redirectUri, ?string $state = null): stringBuild the Twitch authorization URL requesting the user:read:email scope.
Parameters
| Name | Type | Description |
|---|---|---|
| $redirectUri | string | |
| $state | ?string |
TwitchOAuthService::exchangeCode()
public function exchangeCode(string $code, string $redirectUri): Milpa\OAuth\DTO\TwitchUserInfoExchange the authorization code for an access token, then fetch the profile from the Twitch Helix API.
Parameters
| Name | Type | Description |
|---|---|---|
| $code | string | |
| $redirectUri | string |