Get email address from OpenID provider (Janrain openid library)

Posted by Moak on Stack Overflow See other posts from Stack Overflow or by Moak
Published on 2011-09-09T14:05:26Z Indexed on 2012/09/16 21:38 UTC
Read the original article Hit count: 310

Filed under:
|
|
|

When signing in to stackoverflow with google I get this message

Stackoverflow.com is asking for some information from your Google Account [email protected]
•  Email address: [email protected]

However on my site I can log in with openid but I can't ask for the email address. I get this message

 You are signing in to example.com with your Google Account [email protected] 

Also I'm finding it hard to know at what step I need to ask for it, here's some code where I think that step should be built into.

/**
 * Authenticates the given OpenId identity.
 * Defined by Zend_Auth_Adapter_Interface.
 *
 * @throws Zend_Auth_Adapter_Exception If answering the authentication query is impossible
 * @return Zend_Auth_Result
 */
public function authenticate() {

    $id = $this->_id;

    $consumer = new Auth_OpenID_Consumer($this->_storage);

    if (!empty($id)) {

        $authRequest = $consumer->begin($id);

        if (is_null($authRequest)) {
            return new Zend_Auth_Result(
                    Zend_Auth_Result::FAILURE,
                    $id,
                    array("Authentication failed", 'Unknown error'));
        }

        if (Auth_OpenID::isFailure($authRequest)) {
            return new Zend_Auth_Result(
                    Zend_Auth_Result::FAILURE,
                    $id,
                    array("Authentication failed", "Could not redirect to server: " . $authRequest->message));
        }

        $redirectUrl = $authRequest->redirectUrl($this->_root, $this->_returnTo);

        if (Auth_OpenID::isFailure($redirectUrl)) {
            return new Zend_Auth_Result(
                    Zend_Auth_Result::FAILURE,
                    $id,
                    array("Authentication failed", $redirectUrl->message));
        }

        Zend_OpenId::redirect($redirectUrl);

    } else {

        $response = $consumer->complete(Zend_OpenId::selfUrl());

        switch($response->status) {

            case Auth_OpenID_CANCEL:
            case Auth_OpenID_FAILURE:
                return new Zend_Auth_Result(
                        Zend_Auth_Result::FAILURE,
                        null,
                        array("Authentication failed. " . @$response->message));
            break;

            case Auth_OpenID_SUCCESS:
                return $this->_constructSuccessfulResult($response);
            break;
        }
    }
}

It seems like such an obvious thing but I'm having a hard time googling and combing through the code just to find this.

Thanks!

© Stack Overflow or respective owner

Related posts about php

Related posts about zend-framework