oauth-4-laravel is a simple laravel 4 service provider (wrapper) for Lusitanian/PHPoAuthLib witch provides oAuth support in PHP 5.3+ and is very easy to integrate with any project which requires an oAuth client.
- Supported services
- Installation
- Registering the Package
- Configuration
- Usage
- Basic usage
- More usage examples
The library supports both oAuth 1.x and oAuth 2.0 compliant services. A list of currently implemented services can be found below. More services will be implemented soon.
Included service implementations:
-
OAuth1
- FitBit
-
OAuth2
- Microsoft
- GitHub
- BitLy
- Yammer
- SoundCloud
- Foursquare
- Box
- Tumblr
- Vkontakte
To learn more about Lusitanian/PHPoAuthLib go here
Add oauth-4-laravel to your composer.json file:
"require": {
"artdarek/oauth-4-laravel": "dev-master"
}
Use composer to install this package.
$ composer update
Create configuration file using artisan
$ php artisan config:publish artdarek/oauth-4-laravel
Add an alias to the bottom of app/config/app.php
'OAuth' => 'Artdarek\OAuth\facade\OAuth',
and register this service provider at the bottom of the $providers
array:
'Artdarek\OAuth\OAuthServiceProvider',
Add your credentials to app/config/packages/artdarek/oauth-4-laravel/config.php
return array(
/*
|--------------------------------------------------------------------------
| oAuth Config
|--------------------------------------------------------------------------
*/
/**
* Storage
*/
'storage' => 'Session',
/**
* Consumers
*/
'consumers' => array(
/**
* Facebook
*/
'Facebook' => array(
'client_id' => '',
'client_secret' => '',
'scope' => [],
),
)
);
The Storage
attribute is optional and defaults to Session
.
Other options.
Just follow the steps below and you will be able to get a service class object with this one rule:
$fb = OAuth::consumer('Facebook');
Optionally, add a second parameter with the URL which the service needs to redirect to:
$fb = OAuth::consumer('Facebook','http://url.to.redirect.to');
For examples go here