azat
azat

Reputation: 3565

Zend OpenId 2.0 Support

I need to signup a user by OpenId (for example google)
But it is not working!

I have already see some topics:
http://framework.zend.com/issues/browse/ZF-6905
Zend OpenId and Google
And others..

But all of that is not works!

I need to fetch user info (such as login or email) but if I use like this

// $data['openidIdentifier'] = 'https://www.google.com/accounts/o8/id';
public function loginByOpenIdAction() {
    $request = $this->getRequest();
    $form = new Application_Form_UsersLoginByOpenId();

    $this->view->headTitle('Login by OpenId');

    if ($request->isPost()) {
        $data = $request->getPost();
        if ($form->isValid($data)) {
            $consumer = new Zend_OpenId_Consumer();
            $backUrl = $this->getHelper('Url')->url(array('controller' => 'users', 'action' => 'signup-from-open-id'));

            if (!$consumer->login($data['openidIdentifier'], $backUrl)) {
                $this->view->error = 'Can`t connect to OpenId provider';
            }
        }
    }

    $this->view->form = $form;
}

public function signupFromOpenIdAction() {
    $consumer = new Zend_OpenId_Consumer();
    $data = &$_GET;

    $sreg = new Zend_OpenId_Extension_Sreg(array(
        'nickname' => true,
        'email' => false,
        'fullname' => false), null, 1.1
    );

    if ($consumer->verify($data, $id, $sreg)) {
        $properties = $sreg->getProperties();
        var_dump($properties);
        var_dump('allow', $id);
    } else {
        var_dump('deny', $id, $consumer);
    }
    die;
}

And the output is:

string 'deny' (length=4)
string 'https://www.google.com/accounts/o8/id?id=fooBarFooBar' (length=80)
object(Zend_OpenId_Consumer)[61]
  protected '_storage' => 
    object(Zend_OpenId_Consumer_Storage_File)[62]
      private '_dir' => string '/tmp/azat/openid/consumer' (length=25)
  protected '_dumbMode' => boolean false
  protected '_cache' => 
    array
      empty
  private '_httpClient' => null
  private '_session' => null
  private '_error' => string 'Extension::parseResponse failure' (length=32)

Please help: how can i fetch user info from openid server (for example google) for signup user?

If I use $consumer->verify($data, $id) than all ok, but I need user info for signup

And also I use Zend_OpenId_Consumer from this issue http://framework.zend.com/issues/browse/ZF-6905, because with native Zend_OpenId_Consumer $consumer->verify($data, $id) this is not works

Also suggestions to use some brokers, or other libs working with openid not offer.

Upvotes: 2

Views: 1656

Answers (2)

Shane Stillwell
Shane Stillwell

Reputation: 3248

Akeem Philbert has a post and some files you can use to extend the OpenID implementation in ZF to support at least using OpenID with Google.

http://ak33m.com/?p=71

There is also a blog post about getting ZF to work with Facebook and Twitter at

http://shortrecipes.blogspot.com/2011/02/example-of-openid-facebook-and-twitter.html

As @takeshin has pointed out, sadly, ZF doesn't not yet fully support OpenID 2.0.

Upvotes: 4

takeshin
takeshin

Reputation: 50648

AFAIK Zend Framework does not support OpenID 2.0 fully yet.

Please refer to this ZF issue:

http://www.framework.zend.com/issues/browse/ZF-6905?page=com.atlassian.streams.streams-jira-plugin%3Aactivity-stream-issue-tab

You may use other, external libraries instead:

Upvotes: 1

Related Questions