Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/abr4xas/oauth2-twitch
Twitch Helix Provider for OAuth 2.0 Client
https://github.com/abr4xas/oauth2-twitch
hacktoberfest php twitch
Last synced: about 8 hours ago
JSON representation
Twitch Helix Provider for OAuth 2.0 Client
- Host: GitHub
- URL: https://github.com/abr4xas/oauth2-twitch
- Owner: abr4xas
- License: mit
- Created: 2022-10-01T13:47:40.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-10-09T07:55:11.000Z (over 1 year ago)
- Last Synced: 2024-11-24T17:12:31.009Z (about 2 months ago)
- Topics: hacktoberfest, php, twitch
- Language: PHP
- Homepage:
- Size: 28.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
## Twitch Helix Provider for OAuth 2.0 Client
---
[![Latest Version on Packagist](https://img.shields.io/packagist/v/abr4xas/oauth2-twitch.svg?style=flat-square)](https://packagist.org/packages/abr4xas/oauth2-twitch)
[![Tests](https://github.com/abr4xas/oauth2-twitch/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/abr4xas/oauth2-twitch/actions/workflows/run-tests.yml)
[![Total Downloads](https://img.shields.io/packagist/dt/abr4xas/oauth2-twitch.svg?style=flat-square)](https://packagist.org/packages/abr4xas/oauth2-twitch)This package provides Twitch (new version Helix) OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).
### Installation
You can install the package via composer:
```bash
composer require abr4xas/oauth2-twitch
```### Usage
```php
$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("
".print_r($userData, true)."");
} catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {
}
}
```### Testing
```bash
composer test
```### Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
### Contributing
Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.
### Security Vulnerabilities
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
### Credits
- [Angel](https://github.com/abr4xas)
- [All Contributors](../../contributors)### License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.