/** * Retrieves additional profile information which can be needed for first-login(registration) * and which was not provided by first api call. * Returns merged user attributes * @param \yii\authclient\BaseClient $client * @return \yii\authclient\BaseClient Client with merged attributes */ public static function retrieveAdditionalData(\yii\authclient\BaseClient $client) { $attributes = $client->getUserAttributes(); switch ($client->className()) { case 'app\\modules\\user\\authclients\\GitHub': try { $emails = $client->api('user/emails'); foreach ($emails as $email) { if ($email['primary'] === true) { $attributes['email'] = $email['email']; break; } } } catch (\yii\authclient\InvalidResponseException $e) { // no email :-( } break; default: break; } $client->setUserAttributes($attributes); return $client; }