Hello
I have downloaded LightOpenID (http://gitorious.org/lightopenid) few hours ago but still can\'t figure out how to make it work.
I got this google example saved
In your example, there is a line showing how to complete the authentication:
echo 'User ' . ($openid->validate() ? $openid->identity . ' has ' : 'has not ') . 'logged in.';
If $openid->validate()
returns true, it means that the user that claims to be $openid->identity
is authenticated.
If you'd compare it to standard authentication:
$openid->validate()
validate()
returns true, the user is authenticated (with $openid->identity
), so we set a cookie to remember him(or whatever else you want to do on a successful login).Basically, once you confirm that the user is the one who he claims he is (i.e. he has authenticated), you proceed as if it was a normal auth.
Usually, you have to store the identity somewhere, along with a session id.
The username is in $openid->identity
. However, you might want to use a nickname as a displayed name.
Getting a nickname and an email address however, requires additional configuration.
Basically, before calling $openid->authUrl()
, you'd have to add:
$openid->required = array('namePerson/friendly', 'contact/email');
That line would cause LightOpenID to requests these parameters. You can see a list of other parameters (which may or may not be supported by OPs) at axschema.org.
Then, to get the values of those, after calling validate()
, call $openid->getAttributes()
. It will return all avaiable paramerers, for example:
array(
[namePerson/friendly] => Mewp
[contact/email] => mewp@example.com
)
However, be aware of the fact, that this list can contain other parameters and may not contain the ones you requested. Basically, the OP is free to return whatever it wants to, so you need to be prepared for the lack of some values.