Opauth For Laravel 4.x
Version 1.0 - Release Date: 10.05.2016, (*1)
This is based on Opauth - http://opauth.org/, (*2)
Authorize users with your application implementing multiple Oauth2 providers., (*3)
Currently Supported
I've only tested it with Facebook. This does not mean that it won't work for other Oauth2 providers. Refer to http://opauth.org/ for help on implementing it., (*4)
Installation
Run:
composer require fakeheal/opauth-laravel ~dev-laravel-4, (*5)
Or add this to your composer.json:, (*6)
"fakeheal/opauth-laravel": "dev-laravel-4",, (*7)
Usage Example
Install a strategy using composer:, (*8)
composer require opauth/facebook or composer require opauth/twitter, (*9)
Refer to the link that lists all available strategies and how to install them, (*10)
Add this to your app.php array of providers:, (*11)
'Fakeheal\OpauthLaravel\OpauthLaravelServiceProvider', (*12)
Publish the config file and add your strategies:, (*13)
php artisan config:publish fakeheal/opauth-laravel, (*14)
Config options:
https://github.com/opauth/opauth/wiki/Opauth-configuration, (*15)
return [
'Strategy' => array(
'Facebook' => array(
'app_id' => 'APP_ID',
'app_secret' => 'APP_SECRET'
)
),
'security_salt' => 'RANDOM SOME HASH!',
'callback_transport' => 'post',
'path' => '/opauth/social/' //This must match the route for app('opauth')->run();
];
Add this to your routes.php:, (*16)
Route::get('/', function () {
echo '<a href="/opauth/social/facebook">Login with facebook</a>';
});
Route::any('opauth/social/{strategy}/{action?}', function () {
app('opauth')->run();
});
Open:, (*17)
http://localhost:8000/opauth/social/facebook, (*18)
DO NOT FORGET TO CHANGE YOUR APP_ID & APP_SECRET