Wiki

Clone wiki

OAuth / Home

Supported Providers

Please click the following provider icons to learn all about their API helpers.

Note: for the time being, only some Facebook helpers are available, more are coming!

Facebook Google Twitter Yahoo!


Quick Example

#!php

Route::get('/', function()
{
    $google = Google::request('email');

    link_to($google, 'Sign in with Google');
});
#!php

Route::get('dashboard', function()
{
    $id = Google::id();

    $email = Google::email();
});

  1. Ask the user permission to collect his eMail by clicking the link to sign in with Google
  2. Grab the requested information. Note: this example assumes redirect_uri is set to dashboard, see below

Installation

Be sure minimum-stability is set to dev in your composer.json, then run:

composer require cerbero/oauth:2.1.0

Add the service provider to providers and the facades to aliases in app/config/app.php

#!php
'providers' => array(
    'Cerbero\Oauth\OauthServiceProvider',
    ...
),

...

'aliases' => array(
    'Google'   => 'Cerbero\Oauth\Facades\Google',
    'Facebook' => 'Cerbero\Oauth\Facades\Facebook',
    'Twitter'  => 'Cerbero\Oauth\Facades\Twitter',
    'Yahoo'    => 'Cerbero\Oauth\Facades\Yahoo',
    ...
),

Configuration

Create configuration files in app/config/packages/cerbero/oauth by running:

php artisan config:publish cerbero/oauth

Set where the user is redirected after the authorization request, for example dashboard, in _settings.php

#!php

'redirect_uri' => 'dashboard'

You may also choose the storage driver for tokens between redis, memcached, apc, database and file

#!php

'storage' => 'redis'
Leave it to null in order to use the storage driver of the main application.

Every provider has its own configuration file, for example google.php, you can set your application keys there.

Updated