abr4xas / oauth2-twitch
This is my package oauth2-twitch
Fund package maintenance!
abr4xas
Requires
- php: ^8.0
- league/oauth2-client: ^2.6
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- pestphp/pest: ^1.20
- spatie/ray: ^1.28
This package is auto-updated.
Last update: 2024-11-09 10:32:39 UTC
README
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.