Gmailから属性を取得-openid認証
-
11-10-2019 - |
質問
私は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;
}
解決
Googleは、オプションのパラメーターを完全に無視して、必要なパラメーターのみに答えます。
また、次の属性のみを返すことができます。
contact/country/home
contact/email
namePerson/first
namePerson/last
pref/language
それで namePerson
と contact/postalCode/home
うまくいきません。
上記の情報はGoogleに固有であり、Lightopenid自体とはまったく関係ありません。
ライブラリについては、$ lightopenid-> balidate()を2回呼び出すことをお勧めします。それを呼び出すたびに、2番目の要求を拒否する可能性のあるリクエストをプロバイダーに送信します。
他のヒント
$openid->identity = 'https://www.google.com/accounts/o8/';
// use the following line to obtain the required details. These are the only details that google mail provides. This is for lightopenid.
$openid->required = array('namePerson/friendly', 'contact/email' , 'contact/country/home', 'namePerson/first', 'pref/language', 'namePerson/last');
header('Location: ' . $openid->authUrl());
所属していません StackOverflow