Login to an OAuth1 consumer.

@param string                                $provider
@param \OAuth\Common\Service\AbstractService $service

@return Redirect
511247
protected function oauth1Connect($provider, $service)
	{
		if ($oauth_token = Input::get('oauth_token')) {
			try {
				$token = $service->requestAccessToken(
					$oauth_token,
					Input::get('oauth_verifier'),
					$service->getStorage()->retrieveAccessToken($provider)->getRequestTokenSecret()
				);
			} catch (Exception $e) {
				return Redirect::to(Session::pull('mmanos.social.onerror', '/'))
					->with(
						Config::get('laravel-social::error_flash_var'),
						'There was a problem connecting your account (4).'
					);
			}
			
			return $this->processConnect($provider, $service, array(
				'token'  => $token->getAccessToken(),
				'secret' => $token->getAccessTokenSecret(),
			));
		}
		
		try {
			// Extra request needed for oauth1 to get a request token.
			$token = $service->requestRequestToken();
		} catch (Exception $e) {
			return Redirect::to(Session::pull('mmanos.social.onerror', '/'))
				->with(
						Config::get('laravel-social::error_flash_var'),
						'There was a problem connecting your account (5).'
					);
		}
		
		return Redirect::to((string) $service->getAuthorizationUri(array(
			'oauth_token' => $token->getRequestToken(),
		)));
	}
1154349
public function login($provider)
    {
        if (!$this->scopeConfig->getValue(self::CONFIG_PATH_SOCIAL_LOGIN_ENABLED, ScopeInterface::SCOPE_STORE)) {
            return;
        }

        $provider = ucfirst($provider);
        $hybridAuth = $this->hybridauthFactory->create([
            'config' => [
                'callback'  => $this->getCallbackUrl($provider),
                'providers' => $this->getProvidersConfig()
            ]
        ]);

        $adapter = $hybridAuth->authenticate($provider);
        if (!$this->customerSession->isLoggedIn() && $adapter->isConnected()) {
            $profile = $adapter->getUserProfile();
            if ($profile->emailVerified) {
                $customer = $this->getCustomerForProfile($provider, $profile);
                $this->customerSession->setCustomerAsLoggedIn($customer);
            }
        }
    }
1356285
protected function getServiceAuthenticatorsFromRequest($service, HTTPRequest $request)
    {
        $authName = null;

        if ($request->param('ID')) {
            $authName = $request->param('ID');
        }

        // Delegate to a single named handler - e.g. Security/login/<authname>/
        if ($authName && $this->hasAuthenticator($authName)) {
            if ($request) {
                $request->shift();
            }

            $authenticator = $this->getAuthenticator($authName);

            if (!$authenticator->supportedServices() & $service) {
                // Try to be helpful and show the service constant name, e.g. Authenticator::LOGIN
                $constants = array_flip((new ReflectionClass(Authenticator::class))->getConstants());

                $message = 'Invalid Authenticator "' . $authName . '" for ';
                if (array_key_exists($service, $constants)) {
                    $message .= 'service: Authenticator::' . $constants[$service];
                } else {
                    $message .= 'unknown authenticator service';
                }

                throw new HTTPResponse_Exception($message, 400);
            }

            $handlers = [$authName => $authenticator];
        } else {
            // Delegate to all of them, building a tabbed view - e.g. Security/login/
            $handlers = $this->getApplicableAuthenticators($service);
        }

        return $handlers;
    }
1272461
public function register(SecurityServiceProvider $provider)
    {
        $this->provider = $provider;

        if ($this->loginPath) {
            $this->provider->addUnsecurePattern("^{$this->loginPath}$");
        }

        $config = array(
            'logout' => array('logout_path' => $this->logoutPath),
            'pattern' => implode('|', $this->patterns)
        );

        $app = $this->provider->getApp();

        foreach ($this->authFactories as $id => $authFactory) {
            $this->registerAuthenticationFactory($app, $id, $authFactory['factory'], $authFactory['userProvider']);
            $config[$id] = array();
            if ($this->loginPath) {
                $config[$id]['login_path'] = $this->loginPath;
                $config[$id]['check_path'] = $this->loginCheckPath;
            }
        }

        $this->registerUserProvider($app);
        $this->registerContextListener($app);
        $this->registerEntryPoint($app);

        $this->provider->appendFirewallConfig($this->name, $config);
    }
471936
function(provider) {
        if (!this.isCurrent()) {
          return;
        }
        if (_.isString(provider)) {
          provider = AV.User._authProviders[provider];
        }
        if (provider && provider.deauthenticate) {
          provider.deauthenticate();
        }
      }
1127965
public function loginAction(Client $oauthClient, Session $session): RedirectResponse
    {
        // Automatically log in a development user if defined.
        $loggedInUser = $this->getParameter('toolforge.oauth.logged_in_user');
        if ($loggedInUser) {
            $this->get('session')->set('logged_in_user', (object)[
                'username' => $loggedInUser,
            ]);
            return $this->redirectToRoute('home');
        }

        // Otherwise, continue with OAuth authentication.
        [$next, $token] = $oauthClient->initiate();

        // Save the request token to the session.
        $session->set('oauth.request_token', $token);

        // Send the user to Meta Wiki.
        return new RedirectResponse($next);
    }
687477
public static function getServiceName(ServiceInterface $oauthService)
    {
        if ($oauthService instanceof AbstractService) {
            return $oauthService->service();
        }

        return preg_replace('/^.*\\\\/', '', get_class($oauthService));
    }
610291
public function createUserProvider($provider)
    {
        $config = $this->app['config']["auth.providers.{$provider}"];

        // Retrieve the driver from configuration.
        $driver = $config['driver'];

        if (isset($this->customProviderCreators[$driver])) {
            $callback = $this->customProviderCreators[$driver];

            return call_user_func($callback, $this->app, $config);
        }

        switch ($driver) {
            case 'database':
                return $this->createDatabaseProvider($config);

            case 'extended':
                return $this->createExtendedProvider($config);

            default:
                break;
        }

        throw new InvalidArgumentException("Authentication user provider [{$driver}] is not defined.");
    }
1109796
protected function processConnect($provider, $service, $access_token)
	{
		$user_info_callback = Config::get(
			'laravel-social::providers.' . strtolower($provider) . '.fetch_user_info'
		);
		
		if (empty($user_info_callback) || !$user_info_callback instanceof Closure) {
			return Redirect::to(Session::pull('mmanos.social.onerror', '/'))
				->with(
					Config::get('laravel-social::error_flash_var'),
					'There was a problem connecting your account (6).'
				);
		}
		
		try {
			$user_info = $user_info_callback($service);
		} catch (Exception $e) {}
		
		if (empty($user_info) || !is_array($user_info)) {
			return Redirect::to(Session::pull('mmanos.social.onerror', '/'))
				->with(
					Config::get('laravel-social::error_flash_var'),
					'There was a problem connecting your account (7).'
				);
		}
		
		if (empty($user_info['id'])) {
			return Redirect::to(Session::pull('mmanos.social.onerror', '/'))
				->with(
					Config::get('laravel-social::error_flash_var'),
					'There was a problem connecting your account (8).'
				);
		}
		
		$provider_id = array_get($user_info, 'id');
		
		$user_provider = Provider::where('provider', strtolower($provider))
			->where('provider_id', $provider_id)
			->first();
		
		if ($user_provider) {
			if ($user_provider->user_id != Auth::id()) {
				return Redirect::to(Session::pull('mmanos.social.onerror', '/'))
					->with(
						Config::get('laravel-social::error_flash_var'),
						'There was a problem connecting your account (9).'
					);
			}
			
			$user_provider->access_token = $access_token;
			$user_provider->save();
		}
		else {
			$this->linkProvider(Auth::id(), $provider, $provider_id, $access_token);
		}
		
		return Redirect::to(Session::pull('mmanos.social.onsuccess', '/'))
			->with(
				Config::get('laravel-social::success_flash_var'),
				'You have successfully connected your account.'
			);
	}
176009
public function registerServiceProvider(AbstractServiceProvider $provider, array $values = [])
    {
        $this->container->register($provider->setConsole($this), $values);

        return $this;
    }
50364
def login(provider_id):
    """"""
    provider = get_provider_or_404(provider_id)
    callback_url = get_authorize_callback('login', provider_id)
    post_login = request.form.get('next', get_post_login_redirect())
    session[config_value('POST_OAUTH_LOGIN_SESSION_KEY')] = post_login
    return provider.authorize(callback_url)
129269
protected function processLogin($provider, $service, $access_token)
	{
		$user_info_callback = Config::get(
			'laravel-social::providers.' . strtolower($provider) . '.fetch_user_info'
		);
		
		if (empty($user_info_callback) || !$user_info_callback instanceof Closure) {
			return Redirect::to(Session::pull('mmanos.social.onerror', '/'))
				->with(
					Config::get('laravel-social::error_flash_var'),
					'There was a problem logging in to your account (5).'
				);
		}
		
		try {
			$user_info = $user_info_callback($service);
		} catch (Exception $e) {}
		
		if (empty($user_info) || !is_array($user_info)) {
			return Redirect::to(Session::pull('mmanos.social.onerror', '/'))
				->with(
					Config::get('laravel-social::error_flash_var'),
					'There was a problem logging in to your account (6).'
				);
		}
		
		if (empty($user_info['id'])) {
			return Redirect::to(Session::pull('mmanos.social.onerror', '/'))
				->with(
					Config::get('laravel-social::error_flash_var'),
					'There was a problem logging in to your account (7).'
				);
		}
		
		$provider_id = array_get($user_info, 'id');
		
		$user_provider = Provider::where('provider', strtolower($provider))
			->where('provider_id', $provider_id)
			->first();
		
		if ($user_provider) {
			Auth::loginUsingId($user_provider->user_id);
			return Redirect::to(Session::pull('mmanos.social.onsuccess', '/'));
		}
		
		if ($user_validation = Config::get('laravel-social::user_validation')) {
			if ($user_validation instanceof Closure) {
				$validator = $user_validation($user_info);
			}
			else {
				$validator = Validator::make($user_info, (array) $user_validation);
			}
			
			if ($validator && $validator->fails()) {
				Session::put('mmanos.social.pending', array(
					'provider'     => $provider,
					'provider_id'  => $provider_id,
					'user_info'    => $user_info,
					'access_token' => $access_token,
				));
				Session::put('mmanos.social.failed_fields', array_keys($validator->failed()));
				
				return Redirect::action(Config::get('laravel-social::user_failed_validation_redirect'))
					->withErrors($validator);
			}
		}
		
		$create_user_callback = Config::get('laravel-social::create_user');
		if (empty($create_user_callback) || !$create_user_callback instanceof Closure) {
			return Redirect::to(Session::pull('mmanos.social.onerror', '/'))
				->with(
					Config::get('laravel-social::error_flash_var'),
					'There was a problem logging in to your account (8).'
				);
		}
		
		$user_id = $create_user_callback($user_info);
		if (!$user_id || !is_numeric($user_id) || $user_id <= 0) {
			return Redirect::to(Session::pull('mmanos.social.onerror', '/'))
				->with(
					Config::get('laravel-social::error_flash_var'),
					'There was a problem logging in to your account (9).'
				);
		}
		
		$this->linkProvider($user_id, $provider, $provider_id, $access_token);
		
		Auth::loginUsingId($user_id);
		return Redirect::to(Session::pull('mmanos.social.onsuccess', '/'));
	}
54712
public function boot(ProviderRepository $providers)
    {
        if ($this->app->runningInConsole()) {
            $this->registerMigrations();
        }

        $this->createAccessTokenProvider($providers);

        // Register the middleware as singleton to use the same middleware
        // instance when the handle and terminate methods are called.
        $this->app->singleton(\SMartins\PassportMultiauth\Http\Middleware\AddCustomProvider::class);
    }
1305863
protected function createMember(AccessToken $token, AbstractProvider $provider)
    {
        $session = $this->getSession();
        $providerName = $session->get('oauth2.provider');
        $user = $provider->getResourceOwner($token);

        /** @var Member|MemberExtension $member */
        $member = Member::create();
        $member = $this->getMapper($providerName)->map($member, $user);
        $member->OAuthSource = $providerName;
        $member->write();

        return $member;
    }
192627
public function authenticate($provider, $code=False)
    {
        if($code){
            return $this->handleProviderCallback($provider);
        }

        return $this->redirectToProvider($provider);
    }
450726
public function getAccessToken(string $service):AccessToken{

		if($this->hasAccessToken($service)){
			return $this->tokens[$service];
		}

		throw new OAuthStorageException('token not found');
	}
1008456
public static function factory(array $oaResponse) {

		if(empty($oaResponse['auth'])) {
			throw new InvalidArgumentException('The auth key is required to continue.');
		}
		if(empty($oaResponse['auth']['provider'])) {
			throw new InvalidArgumentException('Unable to determine provider.');
		}

		$auth = $oaResponse['auth'];

		$do = OpauthIdentity::get()->filter(
			array(
				'Provider' => $auth['provider'],
				'UID' => $auth['uid'],
			)
		)->first();

		if(!$do || !$do->exists()) {
			$do = new OpauthIdentity();
			$do->Provider = $auth['provider'];
			$do->UID = $auth['uid'];
		}

		$do->setAuthSource($auth);
		return $do;
	}