STANDALONE and SIMPLE!!! OAuth 2.0 identity provider integration.
Go to file
Alex Bilbie d6d06948b8 Added whitelist so that running global phpunit doesn't affect code coverage
On my local system stuff from /usr/local/php was being included
2014-04-26 17:55:20 +01:00
src 100% code coverage 2014-04-25 13:23:09 -07:00
test 100% code coverage 2014-04-25 13:23:09 -07:00
.gitignore Setup base unit testing framework 2014-04-24 15:22:57 -07:00
LICENSE Create LICENSE 2013-11-17 21:16:50 -05:00
README.md Added missing RefreshToken 2014-04-25 12:27:49 -07:00
composer.json Moved tests to test; tidy phpunit.xml 2014-04-25 08:32:38 -07:00
phpunit.xml Added whitelist so that running global phpunit doesn't affect code coverage 2014-04-26 17:55:20 +01:00

README.md

OAuth 2.0 Client Library

Build Status Total Downloads Latest Stable Version

This library makes it stupidly simple to integrate your application with OAuth 2.0 identity providers. It has built in support for:

  • Eventbrite
  • Facebook
  • Github
  • Google
  • Instagram
  • LinkedIn
  • Microsoft
  • Vkontakte

Adding support for other providers is trivial.

The library requires PHP 5.3+ and is PSR-4 compatible.

Usage

$provider = new League\OAuth2\Client\Provider\<provider name>(array(
    'clientId'  =>  'XXXXXXXX',
    'clientSecret'  =>  'XXXXXXXX',
    'redirectUri'   =>  'http://your-registered-redirect-uri/'
));

if ( ! isset($_GET['code'])) {

	// If we don't have an authorization code then get one
    $provider->authorize();

} else {

    try {

    	// Try to get an access token (using the authorization code grant)
        $t = $provider->getAccessToken('authorization_code', array('code' => $_GET['code']));

        // NOTE: If you are using Eventbrite you will need to add the grant_type parameter (see below)
        // $t = $provider->getAccessToken('authorization_code', array('code' => $_GET['code'], 'grant_type' => 'authorization_code'));

        try {

        	// We got an access token, let's now get the user's details
            $userDetails = $provider->getUserDetails($t);

            foreach ($userDetails as $attribute => $value) {
                var_dump($attribute, $value) . PHP_EOL . PHP_EOL;
            }

        } catch (Exception $e) {

            // Failed to get user details

        }

    } catch (Exception $e) {

        // Failed to get access token
	// If you have a refesh token you can use it here:
        $grant = new \League\OAuth2\Client\Grant\RefreshToken();
        $t = $provider->getAccessToken($grant, array('refresh_token' => $refreshToken));
    }
}

List of built-in identity providers

Provider uid nickname name first_name last_name email location description imageUrl urls
Eventbrite string null null null null string null null null null
Facebook string string string string string string string string string array (Facebook)
Github string string string null null string null null null array (Github, [personal])
Google string string string string string string null null string null
Instagram string string string null null null null string string null
LinkedIn string null string null null string string string string string
Microsoft string null string string string string null null string string

Notes: Providers which return URLs sometimes include additional URLs if the user has provided them. These have been wrapped in []

License

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

Bitdeli Badge