How to ask LightOpenId to get the users email in checkid_immediate mode?

810 views Asked by At

Premises:

  • I am using php LightOpenId to authenticate a users through his google account.
  • I am using the standard sample provided (example.php) from the website. Nothing fancy.
  • Adding one line or two to change the behavior.
  • All my clients are Googlers.

Requirement1

I do not want my client to log twice (SSO behavior), so I add the $openid->mode=checkid_immediate before calling header...$openid->authUrl().

I experience 2 problems:

  1. I cannot get the email, lang ... attributes.

    In fact, using checkid_immediate mode and following with the authUrl() I get my user connected correctly as expected.

    BUT Modifying the code and adding the $openid->required to gather the attributes prior the authUrl() request forces my call to be converted into a checkid_setup mode call.

    How can I, in one call, keep the checkid_immediate mode and get my attributes ?

  2. subdomain.mydomain2.com code do not behave like www.mydomain1.com The www.mydomain1.com works fine with the checkid_immediate. The subdomain.mydomain2.com with the same code is converted into a checkid_setup call.

    How can I keep the checkid_immediate mode with a subdomain different than www ?

    Problem #2 solved by itself!!! after clearing cache AND restarting Google Chrome

Thanks in advance.

1

There are 1 answers

3
tiernanx On

As of 0.5 the authUrl method has an optional bool parameter to check immediately. Try:

if (!$openid->mode && !empty($storedIdentity)) {
  $openid->identity = $storedIdentity;
  $openid->required = array('contact/email', 'pref/language');
  header('Location: ' . $openid->authUrl(true));
}

*Edited code example to include question's requested attributes. This presumes $storedIdentity is the identity url returned from checkid_setup previously.