/** * @param string $providerId * @param LegacyOAuthProviderConfig|ProviderConfigLike $config * * @throws \DreamFactory\Oasys\Exceptions\OasysConfigurationException * @return \DreamFactory\Oasys\Providers\BaseLegacyOAuthProvider */ public function __construct($providerId, $config) { if (null === ($_consumerKey = Option::get($config, 'consumer_key')) || null === ($_consumerSecret = Option::get($config, 'consumer_secret'))) { throw new OasysConfigurationException('Invalid or missing credentials.'); } parent::__construct($providerId, $config); $this->_config = $config; // Set up for fetchin' if (2 == $this->getConfig('state')) { $this->_setToken(); } }
/** * @param string $providerId * @param ProviderConfigLike $config * @param string $fromTemplate The template to use if different from $providerId * * @throws \DreamFactory\Oasys\Exceptions\OasysConfigurationException * @return \DreamFactory\Oasys\Providers\BaseOAuthProvider */ public function __construct($providerId, $config = null, $fromTemplate = null) { parent::__construct($providerId, $config, $fromTemplate); // Sanity checks for OAuth if (null === $this->getConfig('client_id') || null === $this->getConfig('client_secret')) { throw new OasysConfigurationException('Invalid or missing credentials.'); } // Set a default redirect URI if none specified if (null === $this->getConfig('redirect_uri')) { Log::debug('Redirect URI set to current URL: ' . ($_url = Curl::currentUrl(false))); $this->setConfig('redirect_uri', $_url); } // Make sure, if specified, certificate file is valid if (null !== ($_certificateFile = $this->getConfig('certificate_file')) && (!is_file($_certificateFile) || !is_readable($_certificateFile))) { throw new OasysConfigurationException('The specified certificate file "' . $_certificateFile . '" was not found or cannot be read.'); } }