chrisnharvey / oauth2
Authorize users in your application with multiple OAuth 2.0 providers
Installs: 42
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 1
pkg:composer/chrisnharvey/oauth2
Requires
- php: >=5.3.0
 - guzzle/guzzle: 3.3.*
 
Requires (Dev)
- mockery/mockery: 0.7.*
 - phpunit/phpunit: 3.7.*
 
This package is auto-updated.
Last update: 2025-10-16 12:51:10 UTC
README
Deprecated: Use league/oauth2-client.
Authorize users with your application using multiple OAuth 2 providers.
Supported Providers
- Appnet
 - Foursquare
 - GitHub
 - Mailchimp
 - Mailru
 - PayPal
 - Soundcloud
 - Vkontakte
 - Windows Live
 - Yandex
 - YouTube
 
Usage Example
In this example we will authenticate the user using Facebook.
$oauth = new \OAuth2\Provider\Facebook(array( 'id' => 'CLIENT_ID', 'secret' => 'CLIENT_SECRET', 'redirect_url' => 'URL_TO_THIS_PAGE' )); if ( ! $oauth->isAuthenticated()) { header("Location: {$oauth->getAuthenticationUrl()}"); exit; } // Tokens print_r($oauth->getUserTokens()); // User data print_r($oauth->getUserInfo());
If all goes well you should see a dump of the users tokens and data.
Calling OAuth 2 APIs using Guzzle
You can also use this package to make calls to your respective APIs using Guzzle.
$client = new \OAuth2\Client('https://graph.facebook.com'); $client->setUserTokens($oauth->getUserTokens()); echo $client->get('me')->send();
This example should show your Facebook profile from the API along with the headers
Contribute
- Check for open issues or open a new issue for a feature request or a bug
 - Fork the repository on Github to start making your changes to the
developbranch (or branch off of it) - Write a test which shows that the bug was fixed or that the feature works as expected
 - Send a pull request and bug me until I merge it