Create an OpAuth instance

@param  array any call-time configuration to be used
@param  bool  whether or not Opauth should run automatically
180669
public static function forge($config = array(), $autorun = true)
	{
		// deal with passing only the autorun value
		if (func_num_args() == 1 and is_bool($config))
		{
			$autorun = $config;
			$config = array();
		}

		// merge the default config with the runtime config
		$config = \Arr::merge(\Config::get('opauth'), $config);

		// define the transport system we use
		$config['callback_transport'] = 'get';

		// make sure we have a remotes table
		if ( ! isset($config['table']) and ($config['table'] = static::$provider_table) === null)
		{
			throw new \OpauthException('No providers table configured. At the moment, only SimpleAuth and OrmAuth can be auto-detected.');
		}

		// and a security salt
		if (empty($config['security_salt']))
		{
			throw new \OpauthException('There is no "security_salt" defined in the opauth.php configuration file.');
		}

		// set some defaults, just in case
		isset($config['security_iteration']) or $config['security_iteration'] = 300;
		isset($config['security_timeout']) or $config['security_timeout'] = '2 minutes';

		if (empty($config['path']))
		{
			$parsed_url = parse_url(\Uri::base().\Request::main()->uri->get());
			$path = explode('/', trim($parsed_url['path'], '/'));

			// construct the path if needed
//			$path = \Request::main()->uri->get_segments();
			$params = count(\Request::active()->route->method_params);

			while ($params-- > 0)
			{
				array_pop($path);
			}
			$config['path'] = '/'.(implode('/', $path)).'/';
		}

		// and construct the callback URL if needed
		if (empty($config['callback_url']))
		{
			// pop the method name from the path
			$path = explode('/', trim($config['path'], '/'));
			array_pop($path);

			// and add 'callback' as the controller callback action
			$config['callback_url'] = '/'.implode('/', $path).'/callback/';
		}

		// determine the name of the provider we want to call
		if ( ! $autorun)
		{
			// we're processing a callback
			$config['provider'] = 'Callback';
		}
		else
		{
			if (empty($config['provider']))
			{
				$parsed_url = parse_url(\Uri::base().\Request::main()->uri->get());
				$provider = explode('/', substr($parsed_url['path'], strlen($config['path'])));
				$config['provider'] = ucfirst($provider[0]);
			}

			// check if we have a strategy defined for this provider
			$strategies = \Config::get('opauth.Strategy', array());
			if ( ! array_key_exists(strtolower($config['provider']), array_change_key_case($strategies)))
			{
				throw new \OpauthException('Opauth strategy "'.$config['provider'].'" is not supported');
			}
		}

		// return the created Auth_Opauth object
		return new static($config, $autorun);
	}
501106
static function create( $orderID, $statusID, $userID = false, $timestamp = false )
    {
        if ( $timestamp === false )
        {
            $timestamp = time();
        }
        if ( $userID === false )
        {
            $userID = eZUser::currentUserID();
        }
        $row = array( 'id' => null,
                      'order_id' => $orderID,
                      'status_id' => $statusID,
                      'modifier_id' => $userID,
                      'modified' => $timestamp );
        return new eZOrderStatusHistory( $row );
    }
934287
public static function create(
        AuthInterface $authentication,
        bool $throwsExceptions = false,
        string $baseUrl = 'https://api.idos.io/1.0/'
    ) : self {
        return new static(
            $authentication,
            new Client(),
            $throwsExceptions,
            $baseUrl
        );
    }
1170112
public function buildFullAuthorizationUri(OAuth2 $oAuth2, $offlineAccess = false, $params = [])
    {
        $defaults = [];

        $params = array_merge(
            $defaults,
            $params
        );

        if ($offlineAccess) {
            $params['access_type'] = 'offline';
        }

        return $oAuth2->buildFullAuthorizationUri($params);
    }
672375
public function ifTrue($bool)
    {
        if (null !== $this->apply) {
            throw new \RuntimeException('Cannot nest ifTrue or ifFalse call');
        }

        $this->apply = (true === $bool);

        return $this;
    }
181990
public static function create($fid, $bool = null)
  {
    if(!is_bool($bool))
    {
      throw new \InvalidArgumentException('Not a valid boolean value');
    }
    return parent::create($fid, $bool);
  }
90763
public function connectOauth1($options)
    {
        $token = false;

        // source oauth provider
        $oauthProvider = $this->getProvider();

        // denied
        if(\Craft\craft()->request->getParam('denied'))
        {
            throw new \Exception("An error occured: ".\Craft\craft()->request->getParam('denied'));
        }

        $user = \Craft\craft()->request->getParam('user');
        $oauth_token = \Craft\craft()->request->getParam('oauth_token');
        $oauth_verifier = \Craft\craft()->request->getParam('oauth_verifier');
        $denied = \Craft\craft()->request->getParam('denied');

        if ($oauth_token && $oauth_verifier)
        {
            $temporaryCredentials = unserialize(\Craft\craft()->httpSession->get('temporary_credentials'));

            $token = $oauthProvider->getTokenCredentials($temporaryCredentials, $oauth_token, $oauth_verifier);

            \Craft\craft()->httpSession->add('token_credentials', serialize($token));

            OauthPlugin::log('OAuth 1.0 Connect - Get token credentials'."\r\n".print_r([
                'temporaryCredentials' => $temporaryCredentials,
                'oauth_token' => $oauth_token,
                'oauth_verifier' => $oauth_verifier,
                'token' => $token,
            ], true), LogLevel::Info);
        }
        elseif ($denied)
        {
        	$errorMsg = "Client access denied by user";

            OauthPlugin::log('OAuth 1.0 Connect - '.$errorMsg, LogLevel::Info);

            throw new \Exception($errorMsg);
        }
        else
        {
            $temporaryCredentials = $oauthProvider->getTemporaryCredentials();

            \Craft\craft()->httpSession->add('temporary_credentials', serialize($temporaryCredentials));

            $authorizationUrl = $oauthProvider->getAuthorizationUrl($temporaryCredentials);
            \Craft\craft()->request->redirect($authorizationUrl);


	        OauthPlugin::log('OAuth 1.0 Connect - Redirect to the authorization URL'."\r\n".print_r([
		        'temporaryCredentials' => $temporaryCredentials,
                'authorizationUrl' => $authorizationUrl,
		    ], true), LogLevel::Info);
        }

        return $token;
    }
1001475
public function ifFalse($bool)
    {
        if (null !== $this->apply) {
            throw new \RuntimeException('Cannot nest ifTrue or ifFalse call');
        }

        $this->apply = (false === $bool);

        return $this;
    }
403604
public function oauth_callback() {
		if (!session_id()) {
			session_start();
		}
		$session = $_SESSION['_opauth_twitter'];
		unset($_SESSION['_opauth_twitter']);

		if (!empty($_REQUEST['oauth_token']) && $_REQUEST['oauth_token'] == $session['oauth_token']) {
			$this->tmhOAuth->config['user_token'] = $session['oauth_token'];
			$this->tmhOAuth->config['user_secret'] = $session['oauth_token_secret'];
			
			$params = array(
				'oauth_verifier' => $_REQUEST['oauth_verifier']
			);
		
			$results =  $this->_request('POST', $this->strategy['access_token_url'], $params);

			if ($results !== false && !empty($results['oauth_token']) && !empty($results['oauth_token_secret'])) {
				$credentials = $this->_verify_credentials($results['oauth_token'], $results['oauth_token_secret']);
				
				if (!empty($credentials['id'])) {
					
					$this->auth = array(
						'uid' => $credentials['id'],
						'info' => array(
							'name' => $credentials['name'],
							'nickname' => $credentials['screen_name'],
							'urls' => array(
								'twitter' => str_replace('{screen_name}', $credentials['screen_name'], $this->strategy['twitter_profile_url'])
							)
						),
						'credentials' => array(
							'token' => $results['oauth_token'],
							'secret' => $results['oauth_token_secret']
						),
						'raw' => $credentials
					);
					
					$this->mapProfile($credentials, 'location', 'info.location');
					$this->mapProfile($credentials, 'description', 'info.description');
					$this->mapProfile($credentials, 'profile_image_url_https', 'info.image');
					$this->mapProfile($credentials, 'url', 'info.urls.website');
					$this->mapProfile($credentials, 'email', 'info.email');
					
					$this->callback();
				}
			}
		} else {
			$error = array(
				'code' => 'access_denied',
				'message' => 'User denied access.',
				'raw' => $_GET
			);

			$this->errorCallback($error);
		}
		
				
	}
297644
public function create(array $args = array()) {
        $this->_overwrite = isset($args['overwrite']) && $args['overwrite'];
        if (isset($args['i']) || isset($args['interactive'])) {
            return $this->_createInteractive();
        }
        $file = $this->_parseFileFromArguments($args);
        $file = APPLICATION_PATH . '/configs/' . $file;
        $this->_createFromFile($file);
        return true;
    }
460047
public function create($username, $password, $callbackUrl = '', $email = '', $description = '', $needsLocation = false)
    {
        $data = array(
            'new_account_username' => strtoupper($username),
            'new_account_passcode' => $password,
            'callback_url'         => $callbackUrl,
            'email'                => $email,
            'description'          => $description,
            'needs_location'       => $needsLocation ? 'true' : 'false',
            'api_token'            => $this->apiToken,
        );

        $this->send('accounts/', InternalRequestInterface::METHOD_POST, $data);
    }
324832
function setDebug($bool)
    {
        $this->dbug = (boolean) $bool;
        $this->cfs_http->setDebug($this->dbug);
    }
827566
function OAuth(opts) {
    if(!(this instanceof OAuth)) {
        return new OAuth(opts);
    }

    if(!opts) {
        opts = {};
    }

    if(!opts.consumer) {
        throw new Error('consumer option is required');
    }

    this.consumer            = opts.consumer;
    this.nonce_length        = opts.nonce_length || 32;
    this.version             = opts.version || '1.0';
    this.parameter_seperator = opts.parameter_seperator || ', ';
    this.realm               = opts.realm;

    if(typeof opts.last_ampersand === 'undefined') {
        this.last_ampersand = true;
    } else {
        this.last_ampersand = opts.last_ampersand;
    }

    // default signature_method is 'PLAINTEXT'
    this.signature_method = opts.signature_method || 'PLAINTEXT';

    if(this.signature_method == 'PLAINTEXT' && !opts.hash_function) {
        opts.hash_function = function(base_string, key) {
            return key;
        }
    }

    if(!opts.hash_function) {
        throw new Error('hash_function option is required');
    }

    this.hash_function = opts.hash_function;
    this.body_hash_function = opts.body_hash_function || this.hash_function;
}
737729
function create($callback = false)
    {

        $index = new Index($this->index, $callback);

        $index->connection = $this->connection;

        return $index->create();
    }
181636
function (options, callback) {

        LOG.debug('preauth#createPreauth called');
        LOG.debug('Validating options');

        try {

            options = new preauthOptions.CreatePreauth().validate(options);

        } catch (err) {

            if (err.name === 'InvalidOption') {

                LOG.error('Invalid options specified: %s', err.message);

                callback(
                    commonErrors.InvalidOption(
                        undefined,
                        {
                            message: err.message
                        }
                    )
                );

            } else {

                LOG.error('System error: %s', err.message);

                callback(
                    commonErrors.SystemError(
                        undefined,
                        {
                            message: err.message
                        }
                    )
                );

            }

            return;

        }

        var timestamp = options.timestamp;

        if (!timestamp) {

            timestamp = new Date().getTime();

        }

        LOG.debug('Generating preauth key');

        var pakCreator = crypto.createHmac('sha1', options.key)
            .setEncoding('hex');

        pakCreator.write(
            util.format(
                '%s|%s|%s|%s',
                options.byValue,
                options.by,
                options.expires,
                timestamp
            )
        );
        pakCreator.end();
        var pak = pakCreator.read();

        LOG.debug('Returning preauth key %s', pak);

        callback(null, pak);

    }
166801
public static function create(?bool $sandbox = false)
    {
        $soapClient = new WSCryptDecryptSoapClient($sandbox);

        return new WSCryptDecrypt($soapClient->getSoapClient());
    }
622590
public static function create($oAuthProvider)
    {
        if (strpos($oAuthProvider, '\\') !== false) {
            if (class_exists($oAuthProvider)) {
                $providerInstance = new $oAuthProvider();
                if (!($providerInstance instanceof AbstractOAuthProvider)) {
                    throw new Exception(
                        sprintf(
                            'OAuth provider "%s" must be extend "AbstractOAuthProvider".',
                            $oAuthProvider
                        )
                    );
                }

                return $providerInstance;
            } else {
                throw new Exception(sprintf('OAuth provider "%s" does not exist.', $oAuthProvider));
            }
        }

        $oAuthClass = 'Rad\\OAuthentication\\Provider\\' .
            Inflection::camelize($oAuthProvider) . 'Provider';

        if (class_exists($oAuthClass)) {
            return new $oAuthClass();
        } else {
            throw new Exception(sprintf('OAuth provider "%s" does not exist.', $oAuthClass));
        }
    }