yii\authclient\clients\GitHub::initUserAttributes PHP Method

initUserAttributes() protected method

protected initUserAttributes ( )
    protected function initUserAttributes()
    {
        $attributes = $this->api('user', 'GET');
        if (empty($attributes['email'])) {
            // in case user set 'Keep my email address private' in GitHub profile, email should be retrieved via extra API request
            $scopes = explode(' ', $this->scope);
            if (in_array('user:email', $scopes, true) || in_array('user', $scopes, true)) {
                $emails = $this->api('user/emails', 'GET');
                if (!empty($emails)) {
                    foreach ($emails as $email) {
                        if ($email['primary'] == 1 && $email['verified'] == 1) {
                            $attributes['email'] = $email['email'];
                            break;
                        }
                    }
                }
            }
        }
        return $attributes;
    }