Question

I'm utilizing LightOpenID and I'm trying to get attributes for this gmail authentication but it doesn't appear to return anything on my personal account and I get no errors. I'm very new to OpenID and was hoping someone could help me out who's done this before.

I'm specifying the fields on validate() and returning them with process()

I'm using the OpenID URL: https://www.google.com/accounts/o8/id

    public function show () {
        if ($this->site->tru->post->isRequest() || !$this->site->tru->get->isEmpty('openid_mode')) {
            require_once $this->site->tru->config->get('root.path').'/lib/php/openid.php';
            $this->lightOpenId = new LightOpenID;
            if ($this->validate() || $this->lightOpenId->validate()) {
                $this->process();
            }
        }

        $this->site->addCss('account/login.css');

        $this->site->addJs('account/login.js');

        echo $this->site->tru->display->getTemplate('/site/account/login.tpl');
    }

    public function process () {
        if ($this->lightOpenId->validate()) {
            echo '<pre>'.print_r($this->lightOpenId).'
'.print_r($this->lightOpenId->getAttributes()).'</pre>';
        }
    }

    public function validate () {
        if (!$this->site->tru->post->isEmpty('openid_url')) {
            $this->lightOpenId->identity = $this->site->tru->post->get('openid_url');
            $this->lightOpenId->optional = array('contact/email', 'namePerson', 'contact/postalCode/home', 'contact/country/home');

            header('Location: '.$this->lightOpenId->authUrl());
        }

        return count($this->error) == 0;
    }
Was it helpful?

Solution

Google answers only to the required parameters, completely ignoring the optional ones.

Also, it can return only following attributes:

contact/country/home
contact/email
namePerson/first
namePerson/last
pref/language

So namePerson and contact/postalCode/home won't work.

The above information are specific to Google, and completely unrelated to LightOpenID itself.

As for the library, I'd advise against calling $lightOpenId->validate() twice. Each time you call it, it sends a request to the provider that might reject the second request.

OTHER TIPS

$openid->identity = 'https://www.google.com/accounts/o8/';

// use the following line to obtain the required details. These are the only details that google mail provides. This is for lightopenid.
$openid->required = array('namePerson/friendly', 'contact/email' , 'contact/country/home', 'namePerson/first', 'pref/language', 'namePerson/last'); 

header('Location: ' . $openid->authUrl());
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top