Introducing the new light weight OAuth Login commercial edition, an OAuth login system for your website with Facebook, Google, Microsoft and Linkedin. OAuth Login is very quick and powerful, sure this helps you to increase your web project registrations. It's definitely a must have login system for every PHP based web projects. Hardly it will take 10 mins for installation.

Database
Users table database design.
CREATE TABLE IF NOT EXISTS `users`
(
id INT(11) NOT NULL AUTO_INCREMENT,
email VARCHAR(200) ,
name VARCHAR(200) ,
first_name VARCHAR(200) ,
last_name VARCHAR(200) ,
gender VARCHAR(10) ,
birthday VARCHAR(20) ,
location VARCHAR(200) ,
hometown VARCHAR(200) ,
bio TEXT,
relationship VARCHAR(30) ,
timezone VARCHAR(10) ,
provider VARCHAR(10) ,
provider_id INT(30) ,
picture TEXT,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;
(
id INT(11) NOT NULL AUTO_INCREMENT,
email VARCHAR(200) ,
name VARCHAR(200) ,
first_name VARCHAR(200) ,
last_name VARCHAR(200) ,
gender VARCHAR(10) ,
birthday VARCHAR(20) ,
location VARCHAR(200) ,
hometown VARCHAR(200) ,
bio TEXT,
relationship VARCHAR(30) ,
timezone VARCHAR(10) ,
provider VARCHAR(10) ,
provider_id INT(30) ,
picture TEXT,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;
The script contains three folders called facebook_lib, google_lib, microsoft_lib, linkedin_lib and images with PHP files.
facebook_lib //Facebook OAUTH library
-- config.php //Facebook app configuration file.
google_lib //Google OAUTH library
-- config.php //Google app configuration file.
microsoft_lib //Microsoft OAUTH library
-- config.php //Microsoft app configuration file.
linkedin_lib //Linkedin OAUTH library
-- config.php //Linkedin app configuration file.
images
db.php //Database connection
OauthLogin.php //Class
facebook_login.php //Facebook Login
google_login.php //Google Login
microsoft_login.php //Microsoft Login
linkedin_login.php //Linkedin Login
index.php
home.php
header.php
redirect.php
logout.php
-- config.php //Facebook app configuration file.
google_lib //Google OAUTH library
-- config.php //Google app configuration file.
microsoft_lib //Microsoft OAUTH library
-- config.php //Microsoft app configuration file.
linkedin_lib //Linkedin OAUTH library
-- config.php //Linkedin app configuration file.
images
db.php //Database connection
OauthLogin.php //Class
facebook_login.php //Facebook Login
google_login.php //Google Login
microsoft_login.php //Microsoft Login
linkedin_login.php //Linkedin Login
index.php
home.php
header.php
redirect.php
logout.php
How to Use
Just call anchor tag with particular service login file.
<a href='facebook_login.php'>Facebook Login</a>
<a href='google_login.php'>Google Login</a>
<a href='microsoft_login.php'>Microsoft Login</a>
<a href='linkedin_login.php'>Linkedin</a>
<a href='google_login.php'>Google Login</a>
<a href='microsoft_login.php'>Microsoft Login</a>
<a href='linkedin_login.php'>Linkedin</a>
How it Works
Facebook & Google Authentication Flowchart


Installation
In this script just you have to modify three file.
db.php
Database configuration file, modify MySQL server details.
<?php
$mysql_hostname = "localhost";
$mysql_user = "username";
$mysql_password = "password";
$mysql_database = "databasename";
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Could not connect database");
mysql_select_db($mysql_database, $bd) or die("Could not select database");
$base_url='http://www.yourwebsite.com/';
?>
$mysql_hostname = "localhost";
$mysql_user = "username";
$mysql_password = "password";
$mysql_database = "databasename";
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Could not connect database");
mysql_select_db($mysql_database, $bd) or die("Could not select database");
$base_url='http://www.yourwebsite.com/';
?>
Application setup details click here.
Facebook Configuration facebook_lib/config.php
You have to create a application. Facebook will provide you app id and app secret id, just replace in the following code.
fbconfig.php
<?php
$facebook_appid='App ID';
$facebook_app_secret='App Secret';
$facebook_scope='email,user_birthday';
$facebook = new Facebook(array(
'appId' => $facebook_appid,
'secret' => $facebook_app_secret,
));
?>
$facebook_appid='App ID';
$facebook_app_secret='App Secret';
$facebook_scope='email,user_birthday';
$facebook = new Facebook(array(
'appId' => $facebook_appid,
'secret' => $facebook_app_secret,
));
?>
Google Configuration google_lib/config.php
You can find this in google_lib folder, here you have to configure application OAuth keys, Consumer keys and redirection callback URL.
// OAuth2 Settings, you can get these keys at https://code.google.com/apis/console Step 6 keys
'oauth2_client_id' => 'Client ID',
'oauth2_client_secret' => 'Client Secret',
'oauth2_redirect_uri' => 'http://www.yoursite.com/google_login.php',
// OAuth1 Settings Step 3 keys.
'oauth_consumer_key' => 'OAuth Consumer Key',
'oauth_consumer_secret' => 'OAuth Consumer Secret',
'oauth2_client_id' => 'Client ID',
'oauth2_client_secret' => 'Client Secret',
'oauth2_redirect_uri' => 'http://www.yoursite.com/google_login.php',
// OAuth1 Settings Step 3 keys.
'oauth_consumer_key' => 'OAuth Consumer Key',
'oauth_consumer_secret' => 'OAuth Consumer Secret',
Microsoft Configuration microsoft_lib/config.php
Click here to launch Microsoft live development dashboard and create an application. Microsoft will provide you Client_Id and Client_Secret.
fbconfig.php
<?php
//Microsoft Application Settings
$microsoft_client_id='Client ID';
$microsoft_client_secret='Client Secret';
$microsoft_scope='wl.basic wl.emails wl.birthday';
$microsoft_redirect_url=$base_url.'microsoft_login.php';
));
?>
//Microsoft Application Settings
$microsoft_client_id='Client ID';
$microsoft_client_secret='Client Secret';
$microsoft_scope='wl.basic wl.emails wl.birthday';
$microsoft_redirect_url=$base_url.'microsoft_login.php';
));
?>
Linkedin Configuration linkedin_lib/config.php
Click here to launch Linkedin developer network and application will provide your App_Key and App_Secret.
fbconfig.php
<?php
//Linkedin Application Settings
$linkedin_appKey='App Key';
$linkedin_appSecret='App Secret';
$linkedin_callbackUrl=$base_url.'linkedin_login.php';
));
?>
//Linkedin Application Settings
$linkedin_appKey='App Key';
$linkedin_appSecret='App Secret';
$linkedin_callbackUrl=$base_url.'linkedin_login.php';
));
?>
Installation Video
Thank You content very good
ReplyDeleteThank you so much... In case I didn't said it before, your 9lessons site has been the BASIS of my understanding of Oauth :)
ReplyDeleteThis is great. have you thought about adding Twitter support into this as well to make it a full suite for social media connection? If you do that, I would surly consider making the purchase.
ReplyDeleteIt's very useful app , thanks
ReplyDeleteI hope it works better than the Google Facebook login script you sold earlier
ReplyDeleteGreat job! But you should not work that way to merge or create new accounts. I mean, a lot of people have more than one e-mail address, if the e-mail on Facebook is not the same on the website he's trying to merge the accounts, your script will create a new account for him.
ReplyDeleteAfter getting the permission from Facebook, the script should always ask the user what he want to do: merge accounts or create a new account.
Amazing!
ReplyDeleteThank You content very good
Can the price be less :)
ReplyDeletegood
ReplyDeleteFantastic
ReplyDeletethanks a lot, its very useful code for every budy
ReplyDeletecool :)
ReplyDeletehi
ReplyDeletecan you help me for yahoo oauth login ?!
give me a tutorial or any things ...
good one
ReplyDeleteHello to all,
ReplyDeleteNice script..i am unable to pay with my cc in Paypal..is anybody tell me how to pay that script
does the script require ssl certificate to be installed on the server?
ReplyDeletethanks
Would you mind telling what do you use for making those diagrams? I really like the way they look both clear and sketchy.
ReplyDeleteThanks in advance.
@Jaime
ReplyDeleteAdobe illustrator
@Naseeb SSL not required
ReplyDeletenice post
ReplyDeleteadd twitter and yahoo too
Great job, but what about adding twitter oauthlogin ?
ReplyDeleteThanks for your great tutorial!
ReplyDeleteThanks.
ReplyDeletereally awesome
ReplyDeleteHello sir,
ReplyDeletenice post and like it
Awesome....
ReplyDeletehey there
ReplyDeleteadd twitter also
thanks
Your demonstration is good keep going on
ReplyDeleteYour demonstration is good keep going on
ReplyDeleteAmazing. I was looking for a script which I can use in my website for facebook and other social media websites login. Thanks for sharing as it really works and solved my problem.
ReplyDeleteAwesome Dear! Very informative tutorial.
ReplyDeleteTwitter is not providing email id
ReplyDeleteTank's Amazing your script
ReplyDeletegreat...I will try to add this to my website
ReplyDeletei love this tutorial, i try and sucess. thanks.
ReplyDeleteJust bought this, can't wait to implement it.
ReplyDeleteJust bought and installed the script. Super easy.
ReplyDeleteOne question - in testing, I added and then removed the app link from my Facebook account. Noticed that there is no logic to update the user table in the database. Would be very useful to have the removal action on the social accounts update the user record in the database to inactive or something... otherwise, any applications will still think the user is associated with their app.
Looks like you need to implement the Deauthorize Callback functionality to remove the user from the database (under Advanced settings in FB at least)
ReplyDeleteIf figured it out.
ReplyDeleteload("id=?",array($fbid));
if ($found){
$rec->deauth= 1;
$rec->save();
}
}
//echo "ok";
function parse_signed_request($signed_request, $secret) {
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
// decode the data
$sig = base64_url_decode($encoded_sig);
$data = json_decode(base64_url_decode($payload), true);
if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
error_log('Unknown algorithm. Expected HMAC-SHA256');
return null;
}
// check sig
$expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
if ($sig !== $expected_sig) {
error_log('Bad Signed JSON signature!');
return null;
}
return $data;
}
function base64_url_decode($input) {
return base64_decode(strtr($input, '-_', '+/'));
}
?>
Last thing - I changed the deauth code to do an update to a new field on the users table called "active". I changed the OuthLogin.php to set that value to 1 when the authorization is occurring and set that value to 0 when the user deauthorizes the app.
ReplyDeleteThat way, you don't lose the users info if you had transactions in your app associated with the user.
Why no Yahoo?
ReplyDeleteit helped me quite a lot!thank you.
ReplyDeleteit helps me quite a lot! thank you!
ReplyDeleteVery good!
ReplyDeleteWhats about the server requirement?
ReplyDeleteI installed it on two virtual machines, it's runs fine on centos but not on ubuntu.
Any tips?
How about twitter login...?
ReplyDeleteHow about twitter login.....?
ReplyDeleteI cannot get the google to work.. I was able to create a client ID and secret for OAuth2 at https://code.google.com/apis/console/ >>> APIs >>> CREDENTIALS .. but when I copy and paste the Client ID and Secret to the google_lib >>> config.php it does not work. b/c I must be missing a step. The written instructions and video instructions seems not so similar and outdated :(
ReplyDeleteThanks for the manual! Everything turned out!
ReplyDeletegoog
ReplyDeleteGreat tutorial. Thanks a lot Srinivas Tamada.I spent more than two weeks to implement social authentication on my site but failed. I wish i could buy this script.
ReplyDeletegood one
ReplyDeleteHello Sir
ReplyDeleteit is great article. I always follow your tutorial to create such auth system. Thankyou.
I used your linkedin auth for my app but i am not able to get full profile from LinkedIn like bio, home town, current city, work detail, education detail and many other things for public profile.
Can you help me in this? It will be great help for me.
Thanks in advance.