abr4xas/oauth2-twitch

This is my package oauth2-twitch

Maintainers

👁 abr4xas

Package info

github.com/abr4xas/oauth2-twitch

pkg:composer/abr4xas/oauth2-twitch

Fund package maintenance!

abr4xas

Statistics

Installs: 6

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 1

v1.0.0 2022-10-01 13:52 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 5aa22e5d98788eb0171c695fdf2eac147a19b894

  • Angel <angel.woop@tepuilabs.dev>

abr4xasoauth2-twitch

This package is auto-updated.

Last update: 2026-06-09 14:20:40 UTC


README

👁 Latest Version on Packagist
👁 Tests
👁 Total Downloads

This package provides Twitch (new version Helix) OAuth 2.0 support for the PHP League's OAuth 2.0 Client.

Installation

You can install the package via composer:

composer require abr4xas/oauth2-twitch

Usage

$twitch = new \Abr4xas\Oauth2Twitch\Provider\Twitch([
 'clientId' => "CLIENT_ID",
 'clientSecret' => "CLIENT_SECRET",
 'redirectUri' => "http://localhost:8000",
]);

// get the authorization url
$url = $twitch->getAuthorizationUrl();

// get user info
if (isset($_GET['code'])) {
 try {
 $token = $twitch->getAccessToken("authorization_code", [
 'code' => $_GET['code'],
 ]);

 $user = $twitch->getResourceOwner($token);

 $userData = $user->toArray();

 // get specific info from your user
 // $user->getDisplayName();
 // $userData->getId()
 // $userData->getType();
 // $userData->getBio();
 // $userData->getEmail();
 // $userData->getPartnered();

 print("<pre>".print_r($userData, true)."</pre>");
 } catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {
 }
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.