cresjie / social-login by cresjie

Laravel authentication with Social Services API
Package Data
Maintainer Username: cresjie
Maintainer Contact: (Cres Jie)
Package Create Date: 2015-02-13
Package Last Update: 2016-02-02
Language: PHP
License: MIT
Last Refreshed: 2021-07-28 03:05:55
Package Statistics
Total Downloads: 46
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 5
Total Watchers: 1
Total Forks: 1
Total Open Issues: 0

Social Login

Laravel 4 Authentication with Social Services API (OAuth2) like Google, Facebook, Yahoo, Github

Installation via Composer

Add this to your composer.json file, in the require object:

 "cresjie/social-login": "v1.0.0.0"

After that, run composer install to install the package.

Add the service provider to app/config/app.php, within the providers array.

 'providers' => array(


Publish the default config file to your application so you can make modifications.

$ php artisan config:publish cresjie/social-login

Add your service provider credentials to the published config file:


for formality set your redirect callback credential to something like: see **Basic usage -> Authentication **


##Login Page

	return SocialLogin::login($provider);

where provider is a social service like google, facebook, etc.. this would redirect the user to the login page for the that social service.


	var_dump( SocialLogin::authenticate($provider) );

after the user logs in to his social service. He/she will be redirected to the url specified in your config file redirect, and just call the SocialLogin::authenticate($provider) to retrieve information

Other Usage

you can also filter results in the config file to have uniform calls. For example retrieving profile picture in google has an array key of picture while in github has an array key of avatar_url

	$results = SocialLogin::authenticate($provider);
	echo $results['picture']; // for goole
	echo $results['avatar_url']; //for github

how about a uniform call.

	$results = SocialLogin::authenticate($provider);
	echo $results['image']; //uniform call

how? just set filter_result in the config file with something like:

	return [
		'google' => [
				'filter_result' => function($result){
					$result['image'] = $result['picture'];
					return $result; //should have return value

		'github' => [
			'filter_result' => function($result){
				$result['image'] = $result['avatar_url'];
				return $result;

we've just add another key to the result value to have a uniform call.. cool!

Access Token

After the user successfully authenticate the login. You can get the access token by calling the method: SocialLogin::getAccessToken()