2017 © Pedro Peláez
 

library oauth2-twitch

A Twitch provider for league/oauth2-client

image

depotwarehouse/oauth2-twitch

A Twitch provider for league/oauth2-client

  • Monday, April 10, 2017
  • by bonywonix
  • Repository
  • 4 Watchers
  • 4 Stars
  • 4,067 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 12 Versions
  • 21 % Grown

The README.md

Twitch provider for league/oauth2-client

This is a package to integrate twitch.tv authentication with the OAuth2 client library by The League of Extraordinary Packages., (*1)

To install, use composer:, (*2)

composer require depotwarehouse/oauth2-twitch

Usage is the same as the league's OAuth client, using \Depotwarehouse\OAuth2\Client\Twitch\Provider\Twitch as the provider. For example:, (*3)

$provider = new \Depotwarehouse\OAuth2\Client\Twitch\Provider\Twitch([
    'clientId' => "YOUR_CLIENT_ID",
    'clientSecret' => "YOUR_CLIENT_SECRET",
    'redirectUri' => "http://your-redirect-uri"
]);

You can also optionally add a scopes key to the array passed to the constructor. The available scopes are documented on the Twitch API Documentation., (*4)

Note: The provider uses the "user_read" scope by default. If you pass other scopes, and want the ->getResourceOwner() method to work, you will need to ensure the "user_read" scope is used., (*5)

if (isset($_GET['code']) && $_GET['code']) {
    $token = $this->provider->getAccessToken("authorization_code", [
        'code' => $_GET['code']
    ]);

    // Returns an instance of Depotwarehouse\OAuth2\Client\Twitch\Entity\TwitchUser
    $user = $this->provider->getResourceOwner($token);

    $user->getDisplayName();
    $user->getId()
    $user->getType();
    $user->getBio();
    $user->getEmail();
    $user->getPartnered();

Testing

You can quickly test that the package works by adding client information (from your twitch.tv account) to config/config.php and then starting up a php server, (*6)

cd test/
php -S localhost:8000

Now, navigating to http://localhost:8000 should present an OAuth flow and then dump your user information., (*7)

The Versions

10/04 2017

dev-master

9999999-dev

A Twitch provider for league/oauth2-client

  Sources   Download

MIT

The Requires

 

10/04 2017

1.3.2

1.3.2.0

A Twitch provider for league/oauth2-client

  Sources   Download

MIT

The Requires

 

10/10 2016

1.3.1

1.3.1.0

A Twitch provider for league/oauth2-client

  Sources   Download

MIT

The Requires

 

13/05 2016

1.3.0

1.3.0.0

A Twitch provider for league/oauth2-client

  Sources   Download

MIT

The Requires

 

04/06 2015

1.2.1

1.2.1.0

A Twitch provider for league/oauth2-client

  Sources   Download

The Requires

 

20/05 2015

1.2.0

1.2.0.0

A Twitch provider for league/oauth2-client

  Sources   Download

The Requires

 

21/03 2015

1.1.0

1.1.0.0

A Twitch provider for league/oauth2-client

  Sources   Download

The Requires

 

21/03 2015

dev-laravel-5

dev-laravel-5

A Twitch provider for league/oauth2-client

  Sources   Download

The Requires

 

02/02 2015

1.0.2

1.0.2.0

A Twitch provider for league/oauth2-client

  Sources   Download

The Requires

 

02/02 2015

1.0.1

1.0.1.0

A Twitch provider for league/oauth2-client

  Sources   Download

The Requires

 

02/02 2015

1.0

1.0.0.0

A Twitch provider for league/oauth2-client

  Sources   Download

The Requires

 

02/02 2015

1.0.3

1.0.3.0

A Twitch provider for league/oauth2-client

  Sources   Download

The Requires