从 GMail 获取属性 - OpenID 身份验证
我正在使用 LightOpenID,并尝试获取此 Gmail 身份验证的属性,但它似乎没有在我的个人帐户上返回任何内容,并且我没有收到任何错误。我对 OpenID 非常陌生,希望有人可以帮助我解决这个问题。
我在 validate()
上指定字段并使用 process()
返回它们
我正在使用 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;
}
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;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Google 仅回答必需的参数,完全忽略可选参数。
此外,它只能返回以下属性:
因此
namePerson
和contact/postalCode/home
将不起作用。以上信息仅针对Google,与LightOpenID本身完全无关。
至于库,我建议不要调用 $lightOpenId->validate() 两次。每次调用它时,它都会向提供者发送一个请求,该提供者可能会拒绝第二个请求。
Google answers only to the required parameters, completely ignoring the optional ones.
Also, it can return only following attributes:
So
namePerson
andcontact/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.