使用yii2获取gmail帐户

时间:2015-05-04 17:43:00

标签: php yii2

我已经实施了扩展程序EAuth Yii2,以便通过Gmail进行身份验证。 直到现在,除了我无法获得用户的邮件之外,这一切都很好,这个方法选择我的用户名,ID,谷歌加帐户但不带给我邮件帐户。并在谷歌看看,找不到解决方案,有人我救命,拜托。 YII :: $ APP->用户&GT同一性

1 个答案:

答案 0 :(得分:0)

I answer myself, because I found the solution and put it in case someone else's worth it:

  1. Edit file GoogleOAuth2Service.php
  2. Change the 'scope' of the next line:

    protected $scopes = array(self::SCOPE_USERINFO_PROFILE);

  3. For this other:

    protected $scopes = array(self::SCOPE_USERINFO_EMAIL);

  4. And finally display the mail attribute.

    $this->attributes['email'] = $info['email'];