/** * Instantiate the given provider and authentication or authorization protocol. * * If user not authenticated yet, the user will be redirected to the authorization Service * to authorize the application. * * @param string $provider Provider (case insensitive) * * @throws Exception\Exception * @throws Exception\RuntimeException * @throws Exception\UnexpectedValueException * @throws Exception\InvalidArgumentException * @throws Exception\AuthorizationDeniedException * @throws Exception\HttpClientFailureException * @throws Exception\HttpRequestFailedException * @throws Exception\InvalidAccessTokenException * @throws Exception\InvalidApplicationCredentialsException * @throws Exception\InvalidAuthorizationCodeException * @throws Exception\InvalidAuthorizationStateException * @throws Exception\InvalidOauthTokenException * @throws Exception\InvalidOpenidIdentifierException * * @return Adapter\AdapterInterface */ public function authenticate($provider) { $this->logger->info("Enter Hybridauth::authenticate( {$provider} )"); $adapter = $this->getAdapter($provider); $adapter->authenticate(); return $adapter; }
/** * Common adapters constructor. * * @param array $config * @param HttpClientInterface $httpClient * @param StorageInterface $storage * @param LoggerInterface $logger */ public function __construct($config = [], HttpClientInterface $httpClient = null, StorageInterface $storage = null, LoggerInterface $logger = null) { $this->providerId = str_replace('Hybridauth\\Provider\\', '', get_class($this)); $this->storage = $storage ?: new Session(); $this->logger = $logger ?: new Logger(isset($config['debug_mode']) ? $config['debug_mode'] : Logger::NONE, isset($config['debug_file']) ? $config['debug_file'] : ''); $this->httpClient = $httpClient ?: new HttpClient(); if (isset($config['curl_options']) && method_exists($this->httpClient, 'setCurlOptions')) { $this->httpClient->setCurlOptions($this->config['curl_options']); } if (method_exists($this->httpClient, 'setLogger')) { $this->httpClient->setLogger($this->logger); } $this->logger->debug('Initialize ' . get_class($this) . '. Provider config: ', $config); $this->config = new Data\Collection($config); $this->endpoint = $this->config->get('callback'); $this->initialize(); }