OAuth 1.0 and 2.0 Client for Laravel
This package is built upon The PHP League's OAuth Client libraries., (*1)
It provides facades for the packaged servers/providers and unites the API across both., (*2)
I understand that may seem strange, since there is different language associated with each version, but it makes it easier to use both, (*3)
Disclaimer
This has only been tested using authentication and getting user details. I haven't attempted to use these to make further API calls yet., (*4)
Requirements
from OAuth 2.0 Client, (*5)
The following versions of PHP are supported., (*6)
- PHP 5.4
- PHP 5.5
- PHP 5.6
- HHVM
Servers/Providers included
- OAuth 1.0
- OAuth 2.0
- Eventbrite
- Facebook
- Github
- Google
- Instagram
- LinkedIn
- Microsoft
Package Installation
Add the following line to your composer.json file:, (*7)
"kalley/laravel-oauth-client": "dev-master"
or run composer require kalley/laravel-oauth-client:dev-master from the command line, (*8)
Add this line of code to the providers array located in your app/config/app.php file:, (*9)
'Kalley\LaravelOauthClient\LaravelOauthClientServiceProvider',
Configuration
In order to use the OAuth Client, publish its configuration first, (*10)
php artisan config:publish kalley/laravel-oauth-client
Afterwards edit the file app/config/packages/kalley/laravel-oauth-client/oauth-client.php to suit your needs., (*11)
You will probably want to go ahead and add Facades for the providers you're planning to use as well. For example, if you were integration Facebook:, (*12)
'Facebook' => 'Kalley\LaravelOauthClient\Facades\FacebookFacade',
and so on. If you don't do this, you can call them using App::make('oauth-client.facebook');, (*13)
These will return an instance of the AbstractOAuthClient class., (*14)
Migrations
This package comes with all the migrations you need to run a full featured oauth2 server. Run:, (*15)
php artisan oauth-client:migrations
Usage
User authorization
This will take care of everything, including the redirection to the service, (*16)
Facebook::authorize();
Getting the access token
For OAuth 1.0:
```
$token = Twitter::getAccessToken(['oauth_token' => Input::get('oauth_token'), 'oauth_verifier' => Input::get('oauth_verifier')]);
```
For OAuth 2.0:
```
$token = Facebook::getAccessToken(Input::get('code'));
```
Getting user details
You will need to get the access token first., (*17)
$social_user = Facebook::getUserDetails();
After that, it's pretty much up to you at this point. If you want to get a better idea of what is going on, please take a look at the required packages:, (*18)
Support
Bugs and feature request are tracked on GitHub, (*19)
License
This package is released under the MIT License., (*20)
Credit
The code on which this package is based is primarily developed and maintained by Alex Bilbie., (*21)