Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chrisnharvey/oauth2
Authorize users in your application with multiple OAuth 2.0 providers.
https://github.com/chrisnharvey/oauth2
Last synced: about 4 hours ago
JSON representation
Authorize users in your application with multiple OAuth 2.0 providers.
- Host: GitHub
- URL: https://github.com/chrisnharvey/oauth2
- Owner: chrisnharvey
- Created: 2013-03-16T10:34:11.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-05-28T20:27:01.000Z (over 9 years ago)
- Last Synced: 2024-05-01T23:30:04.731Z (7 months ago)
- Language: PHP
- Size: 206 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# OAuth 2.0 Composer Package
_Deprecated: Use [league/oauth2-client](https://github.com/thephpleague/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.
```php
$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.```php
$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
1. Check for open issues or open a new issue for a feature request or a bug
2. Fork [the repository][] on Github to start making your changes to the
`develop` branch (or branch off of it)
3. Write a test which shows that the bug was fixed or that the feature works as expected
4. Send a pull request and bug me until I merge it[the repository]: https://github.com/chrisnharvey/oauth2