Obtain the user information from Eve Online.

@param \Laravel\Socialite\Contracts\Factory $social

@return \Seat\Web\Http\Controllers\Auth\Response
@throws \Seat\Services\Exceptions\SettingException
550076
public function handleProviderCallback(Socialite $social)
    {

        $eve_data = $social->driver('eveonline')->user();

        // Avoid self attachment
        if (auth()->check() && auth()->user()->id == $eve_data->character_id)
            return redirect()->route('home')
                ->with('error', 'You cannot add yourself. Did you forget to change character in Eve Online SSO form ?');

        // Get or create the User bound to this login.
        $user = $this->findOrCreateUser($eve_data);

        // Update the refresh token for this character.
        $this->updateRefreshToken($eve_data);

        if (! $this->loginUser($user))
            return redirect()->route('auth.login')
                ->with('error', 'Login failed. Please contact your administrator.');

        // ensure the user got a valid group - spawn it otherwise
        if (is_null($user->group)) {
            Group::forceCreate([
                'id' => $user->group_id,
            ]);

            // force laravel to update model relationship information
            $user->load('group');
        }

        // Set the main characterID based on the response.
        $this->updateMainCharacterId($user);

        return redirect()->intended();
    }
32031
public function getOauthClient($forceNew = false)
    {
        if ( ! isset($this->instances[self::CLIENT_OAUTH]) || $forceNew) {
            $this->instances[self::CLIENT_OAUTH] = MeetupOAuthClient::factory($this->getUpdatedOauthConfig());
        }

        return $this->instances[self::CLIENT_OAUTH];
    }
224672
public function getUser( $snsUser, $accessToken ) {

		$snsProfile = $this->getByTypeSnsId( SnsConnectGlobal::SNS_TYPE_FACEBOOK, $snsUser->id );

		$user = null;

		if( isset( $snsProfile ) ) {

			$snsProfile	= $this->update( $snsProfile, [ 'snsUser' => $snsUser, 'accessToken' => $accessToken ] );

			$user = $snsProfile->user;

			return $user;
		}
		else if( isset( $snsUser->email ) ) {

			$user = $this->userService->getByEmail( $snsUser->email );

			if( !isset( $user ) ) {

				// Create User
				$user = $this->register( $snsUser );

				// Add User to current Site
				$this->siteMemberService->createByParams( [ 'userId' => $user->id ] );

				// Trigger Mail
				Yii::$app->snsLoginMailer->sendRegisterFacebookMail( $user );
			}

			$snsProfile	= $this->create( $user, [ 'snsUser' => $snsUser, 'accessToken' => $accessToken ] );

			return $user;
		}

		return false;
	}
21139
public function authenticateSocial($authResponse)
	{
		$this->debug->groupCollapsed(__METHOD__);
		$return = false;
		$providerkey = $authResponse['auth']['uid'];
		$query = 'SELECT * FROM `user_social` WHERE `providerkey` = '.$this->db->quoteValue($providerkey);
		$users = $this->db->query($query)[0];
		$this->debug->table($users, 'users');
		if ($users) {
			$userid = $users[0]['userid'];
			$this->log('login', $userid, array('provider'=>$authResponse['auth']['provider']));
			$return = $userid;
		}
		$this->debug->groupEnd();
		return $return;
	}
523319
public function getConnect($provider = null)
	{
		if (empty($provider)) {
			App::abort(404);
		}
		
		$referer = Request::header('referer', '/');
		$referer_parts = parse_url($referer);
		$onboth = array_get($referer_parts, 'path');
		if (array_get($referer_parts, 'query')) {
			$onboth .= '?' . array_get($referer_parts, 'query');
		}
		
		if (!Input::get('code') && !Input::get('oauth_token')) {
			Session::put('mmanos.social.onsuccess', Input::get('onsuccess', $onboth));
			Session::put('mmanos.social.onerror', Input::get('onerror', $onboth));
		}
		
		if (!Auth::check()) {
			return Redirect::to(Session::pull('mmanos.social.onerror', '/'))
				->with(
					Config::get('laravel-social::error_flash_var'),
					'There was a problem connecting your account (1).'
				);
		}
		
		if (Input::get('denied') || Input::get('error')) {
			return Redirect::to(Session::pull('mmanos.social.onerror', '/'))
				->with(
					Config::get('laravel-social::error_flash_var'),
					'There was a problem connecting your account (2).'
				);
		}
		
		$provider = ucfirst($provider);
		
		try {
			$service = Social::service($provider);
			
			if (Config::get('laravel-social::providers.' . strtolower($provider) . '.offline')) {
				$service->setAccessType('offline');
			}
		} catch (Exception $e) {
			App::abort(404);
		}
		
		if (2 === Social::oauthSpec($provider)) {
			return $this->oauth2Connect($provider, $service);
		}
		else {
			return $this->oauth1Connect($provider, $service);
		}
	}
1233355
public function addSocial(AbstractUser $socialUser, $provider)
    {
        $refreshToken = isset($socialUser->refreshToken) && $socialUser->refreshToken
            ? $socialUser->refreshToken
            : null;
        
        $token = is_null($socialUser->token)
            ? $provider
            : $socialUser->token;

        $this->socials()->create([
            'provider'      => $provider,
            'social_id'     => $socialUser->getId(),
            'email'         => $socialUser->getEmail(),
            'avatar'        => $socialUser->getAvatar(),
            'token'         => $token,
            'refresh_token' => $refreshToken,
            'expires_in'    => isset($socialUser->expiresIn) ? $socialUser->expiresIn : null,
        ]);
    }
434157
public function initSdk() {
    $class_name = '\Google_Client';

    if (!class_exists($class_name)) {
      throw new SocialApiException(sprintf('The PHP SDK for Google Services could not be found. Class: %s.', $class_name));
    }

    if (!$this->validateConfig($this->settings)) {
      return FALSE;
    }

    $client = new $class_name();
    $client->setClientId($this->settings->getClientId());
    $client->setClientSecret($this->settings->getClientSecret());

    return $client;
  }
658627
public function getSymfonyResponse($settings = null)
    {
        $headers = static::getCORSResponseHeaders();

        if (static::isOptionsRequest()) {
            return new \Symfony\Component\HttpFoundation\Response('', 200, $headers);
        }

        if (!$settings) {
            $settings = $this->getSettings();
        }
        $data = $this->getResponseObject($settings);

        $data['remote'] = [
            'url' => $settings->getFetchUrl(),
            'refreshAfter' => $this->refreshAfter
        ];
        $data['remote'][$settings->getFetchUrl()] = $data['settings']['main'];

        $response = new \Symfony\Component\HttpFoundation\JsonResponse($data, 200, $headers);

        if (($callback = $this->getCallback())) {
            $response->setCallback($callback);
        }

        return $response;
    }
789905
public function getSocialProviderByUserName(SocialProvider &$social_provider)
		{
			$form_data = array(
				'username' => $social_provider->getUsername(),
				'provider' => $social_provider->getProviderName()
			);
			$xml = $this->call('getsocialproviderbyusername', $form_data);
			$xml = $xml->Data;

			$social_provider
				->setProviderId((int)$xml->social_provider_id);
		}
1039072
public function getProfile($type) {
    $sdk = $this->getSdk($type);
    $data_handler = $this->networkManager->createInstance('social_auth_twitter')->getDataHandler();

    // Get the OAuth token from Twitter.
    if (!($oauth_token = $data_handler->get('oauth_token')) || !($oauth_token_secret = $data_handler->get('oauth_token_secret'))) {
      drupal_set_message($this->t('@network login failed. Token is not valid.', [
        '@network' => $this->t('Twitter'),
      ]), 'error');
      return $this->redirect('user.' . $type);
    }

    $this->authManager->setAccessToken([
      'oauth_token' => $oauth_token,
      'oauth_token_secret' => $oauth_token_secret,
    ]);

    // Gets the permanent access token.
    $this->accessToken = $sdk->oauth('oauth/access_token', [
      'oauth_verifier' => $this->request->get('oauth_verifier'),
    ]);

    $this->authManager->setAccessToken([
      'oauth_token' => $this->accessToken['oauth_token'],
      'oauth_token_secret' => $this->accessToken['oauth_token_secret'],
    ]);

    // Get user's profile from Twitter API.
    if (!($profile = $this->authManager->getProfile()) || !$this->authManager->getAccountId()) {
      drupal_set_message($this->t('@network login failed, could not load @network profile. Contact the site administrator.', [
        '@network' => $this->t('Twitter'),
      ]), 'error');
      return $this->redirect('user.' . $type);
    }

    return $profile;
  }
1082433
public function socialProfileAction()
    {
        if ($spId = $this->params()->fromQuery('spId')) {
            $repositories = $this->repositories;
            $repo = $repositories->get('Applications/Application');
            $profile = $repo->findProfile($this->params()->fromQuery('spId'));
            if (!$profile) {
                throw new \InvalidArgumentException('Could not find profile.');
            }
        } elseif ($this->getRequest()->isPost()
                   && ($network = $this->params()->fromQuery('network'))
                   && ($data    = $this->params()->fromPost('data'))
        ) {
            $profileClass = '\\Auth\\Entity\\SocialProfiles\\' . $network;
            $profile      = new $profileClass();
            $profile->setData(\Zend\Json\Json::decode($data, \Zend\Json\Json::TYPE_ARRAY));
        } else {
            throw new \RuntimeException(
                'Missing arguments. Either provide "spId" as Get or "network" and "data" as Post.'
            );
        }
        
        return array(
            'profile' => $profile
        );
    }
841712
public function fetch() {
        $params = Values::of(array());

        $payload = $this->version->fetch(
            'GET',
            $this->uri,
            $params
        );

        return new SettingsInstance($this->version, $payload);
    }
966850
public function initSdk() {
    $class_name = '\Facebook\Facebook';

    if (!class_exists($class_name)) {
      throw new SocialApiException(sprintf('The PHP SDK for Facebook could not be found. Class: %s.', $class_name));
    }

    if (!$this->validateConfig($this->settings)) {
      return FALSE;
    }

    $settings = [
      'app_id' => $this->settings->getAppId(),
      'app_secret' => $this->settings->getAppSecret(),
      'default_graph_version' => 'v' . $this->settings->getGraphVersion(),
      'persistent_data_handler' => $this->getDataHandler(),
    ];

    return new $class_name($settings);
  }
513181
protected function updateFromProvider($user, $socialUser)
    {
        if (! $user->hasProvider($this->provider->driver)) {
            return $user->addSocial($socialUser, $this->provider->driver);
        }

        return $user->getProvider($this->provider->driver)
            ->updateFromProvider($socialUser, $this->provider->driver);
    }
205174
public function settings()
    {
        if (is_null($this->settingRequests)) {
            $this->settingRequests = new SettingRequests($this->client);
        }

        return $this->settingRequests;
    }
715095
public function find($socialUser)
    {
        return SocialUser::where('social_id', $socialUser->id)
               ->where('social_type', $this->provider)->first();
    }
149292
public function getUser($credentials, UserProviderInterface $userProvider): ?UserInterface
    {
        $token = $this->userProvider->getDecodedToken($credentials['jwt']);
        $clientKey = $token->iss;

        if (!$clientKey) {
            throw new AuthenticationException(
                \sprintf('API Key "%s" does not exist.', $credentials['jwt'])
            );
        }

        /** @var TenantInterface|UserInterface $user */
        $user = $this->userProvider->loadUserByUsername($clientKey);
        if (\property_exists($token, 'sub')) {
            // for some reasons, when webhooks are called - field sub is undefined
            $user->setUsername($token->sub);
        }

        return $user;
    }