openidlightopenid

LightOpenID giving errors with default setup, and returning false with valid login


Using the LightOpenID class, I am trying to get Google's login integrated with my site. I'm using the default code:

<?php
require 'includes/openid.php';

try {
    if(!isset($_GET['openid_mode'])) {
        if(isset($_GET['login'])) {
            $openid = new LightOpenID;
            $openid->identity = 'https://www.google.com/accounts/o8/id';
            header('Location: ' . $openid->authUrl());
        }
?>
<form action="?login" method="post">
    <button>Login with Google</button>
</form>
<?php
    } elseif($_GET['openid_mode'] == 'cancel') {
        echo 'User has canceled authentication!';
    } else {
        $openid = new LightOpenID;
        echo 'User ' . ($openid->validate() ? $openid->identity . ' has ' : 'has not ') . 'logged in.';
    }
} catch(ErrorException $e) {
    echo $e->getMessage();
}
echo '<pre>'.print_r($openid,true).'</pre>';
?>

Originally, this was telling me I was missing argument 1 for the construct method, forcing me to to call the new LightOpenID method as new LightOpenID($host). But since I had changed it and tried logging in, it's not giving that error when I reverted the code back just go grab the error...

Anyway, that point aside, after I added the host I was taken to the google page where it asked if I wanted to sign into the site with my google account. I pressed the sign-in button and was taken back only to be told that I was not signed in.

User has not logged in.

LightOpenID Object
(
    [returnUrl] => myReturnURL
    [required] => Array
        (
        )

    [optional] => Array
        (
        )

    [verify_peer] => 
    [capath] => 
    [cainfo] => 
    [data] => Array
        (
            [login] => 
            [openid_ns] => http://specs.openid.net/auth/2.0
            [openid_mode] => id_res
            [openid_op_endpoint] => https://www.google.com/accounts/o8/ud
            [openid_response_nonce] => 2012-07-23T14:06:24ZQwlS1zWFRdvg6A
            [openid_return_to] => myReturnURL
            [openid_assoc_handle] => AMlYA9WMwp_rTkH3swNLEF5UASFvhyOR-kqVSXGe7cvXe7ws5z8HHWUu
            [openid_signed] => op_endpoint,claimed_id,identity,return_to,response_nonce,assoc_handle
            [openid_sig] => NtOEY8dUM1Hpt2tTR9x0RdN5o1c=
            [openid_identity] => https://www.google.com/accounts/o8/id?id=AItOawkXNCi5qq-3Vj_esgSQAwmEN_nVIC8BHAQ
            [openid_claimed_id] => https://www.google.com/accounts/o8/id?id=AItOawkXNCi5qq-3Vj_esgSQAwmEN_nVIC8BHAQ
        )

    [identity:LightOpenID:private] => 
    [claimed_id:LightOpenID:private] => https://www.google.com/accounts/o8/id?id=AItOawkXNCi5qq-3Vj_esgSQAwmEN_nVIC8BHAQ
    [server:protected] => https://www.google.com/accounts/o8/ud
    [version:protected] => 2
    [trustRoot:protected] => mySite
    [aliases:protected] => 
    [identifier_select:protected] => 
    [ax:protected] => 1
    [sreg:protected] => 
    [setup_url:protected] => 
    [headers:protected] => Array
        (
            [cache-control] => no-cache, no-store, max-age=0, must-revalidate
            [pragma] => no-cache
            [expires] => Fri, 01 Jan 1990 00:00:00 GMT
            [date] => Mon, 23 Jul 2012 14:06:26 GMT
            [content-type] => text/plain; charset=UTF-8
            [x-content-type-options] => nosniff
            [x-frame-options] => SAMEORIGIN
            [x-xss-protection] => 1; mode=block
            [server] => GSE
        )

)

I was already signed into Google, so the Google page did not ask me to log in, just to verify that I wanted to sign into my own website using my Google account. Does anyone see a reason why it is not saying I am signed in?

Thanks in advance.


Solution

  • Use the newest version, and it should work.

    Just remember that the newer versions of the library require an argument in the constructor:

    $openid = new LightOpenId('www.domain.com');