Thursday, October 20, 2011

Website Login with Google Account, Yahoo Account with Oauth

Website registration and Login forms have important aspect of our development process. Currently visitors were not interested to fill large forms in any website. In this case visitors are not willing to join by signup on our website. In this aspect, technology will a solution. that is open social login from other major services. By this way, we can be use Login from google, yahoo, facebook, twitter.


First, Let us create a open login for our website login or registration form with Google Account and Yahoo Mail. upcoming days we will see other services. Now we can create website Login with OpenID OAuth Login with Google Accounts and Yahoo Accounts.

let us create How to make people login into your website with their Google account and Yahoo
Google and Yahoo provides Federated Login for Account Users with OAuth.

Step: 1
Download LightOpenID Class from
https://nodeload.github.com/brice/LightOpenId/zipball/master


Step: 2: Write a Following Code and design a Form to Handle Login

<?php session_start();
# Logging in with Google accounts requires setting special identity, so this example shows how to do it.
require 'require/openid.php';

try {
    # Change 'localhost' to your domain name.
    $openid = new LightOpenID('demos.w3lessons.com');
 
  $openid->required = array(
  'namePerson',
  'namePerson/first',
  'namePerson/last',
  'contact/email',
  );

    if(!$openid->mode) {
  
 if(@$_GET['auth']=="google")
    {
  $_SESSION['auth']="Google";
        $openid->identity = 'https://www.google.com/accounts/o8/id';
        header('Location: ' . $openid->authUrl());
 }elseif(@$_GET['auth']=="yahoo")
 {
  $_SESSION['auth']="Yahoo";
  $openid->identity ='yahoo.com';
  header("Location:".$openid->authUrl());
 }

    } elseif($openid->mode == 'cancel') {
        echo 'User has canceled authentication!';
    } else {
   $external_login=$openid->getAttributes();
   $_SESSION['name']=$external_login['namePerson/first']." ".$external_login['namePerson/last'];
   $_SESSION['email']=$external_login['contact/email'];
   header("Location:account-home.php");
   exit();
   
    }
} catch(ErrorException $e) {
    echo $e->getMessage();
}
?>


Download This Script     Live Demo     Download Script

17 comments:

  1. This is very help full to my projects, Thanks guys

    ReplyDelete
    Replies
    1. IEEE Project Domain management in software engineering is distinct from traditional project deveopment in that software projects have a unique lifecycle process that requires multiple rounds of testing, updating, and faculty feedback. A IEEE Domain project Final Year Projects for CSE system development life cycle is essentially a phased project model that defines the organizational constraints of a large-scale systems project. The methods used in a IEEE DOmain Project systems development life cycle strategy Project Centers in Chennai For CSE provide clearly defined phases of work to plan, design, test, deploy, and maintain information systems.


      This is enough for me. I want to write software that anyone can use, and virtually everyone who has an internet connected device with a screen can use apps written in JavaScript. JavaScript Training in Chennai JavaScript was used for little more than mouse hover animations and little calculations to make static websites feel more interactive. Let’s assume 90% of all websites using JavaScript use it in a trivial way. That still leaves 150 million substantial JavaScript Training in Chennai JavaScript applications.

      Delete
  2. thanks for the good, OAuth login

    ReplyDelete
  3. I find what i need to do my website login at here thanks.

    ReplyDelete
  4. On running the script i get this error
    No OpenID Server found at http://yahoo.com/
    What is missing?
    Rgds. Tim

    ReplyDelete
  5. Nice, I had a hard time using the federated login.

    However, $_SESSION['email'] is blank with Y! login.

    ReplyDelete
  6. How we get google and yahoo account profile picture through this script? please give me soloution

    ReplyDelete
  7. Hi, this article is not explaining oauth.. it explains login with openid. With openid there is a limited ammount of data you can ask for, basically email, first name, last name, etc.

    To get the picture, you need to access yahoo|google api, which you can do with oauth.. not with openid.

    ReplyDelete
  8. OpenID identity URL has been updated by Yahoo use following URL:

    "http://open.login.yahooapis.com/openid20/www.yahoo.com/xrds"

    ReplyDelete
  9. Please help me....session not destroyed when logout
    clicked on

    ReplyDelete
  10. when ever login through open id first time goes to google login page submit the form after that details are captured and displayed into account-home.php..this process is fine...My question is i clicked on logout button session is cleared and goto index page then again i click on google button it will directly goes to account-home.php without asking google login but i want google login screen...is there any possibility go for again google login page.....Please help me, I need that way.....thanking you.

    ReplyDelete
  11. Hi Sir,

    I have downloaded Ur Script and kept in Apache. When I tried to logion with gmail, it throwing "Failed to connect to 2404:6800:4003:802::1011: Network is unreachable" error. Please help me in this regard. Is there any server/configuration required to work it?

    ReplyDelete
  12. hii.
    i don't know how we can use this code plase help me.

    ReplyDelete
  13. properly on your iPhone your can contact Apple Customer Care or Yahoo Customer Care to let them know of this problem and get proper solution. yahoo mail login

    ReplyDelete