Create an API key for account

@return string|boolean JSON encode key or false
422693
public function createApiKey()
	{
        if (!isset($this->token)) {
            return false;
        }

        $authHeader = 'LP-Security-Token';
        if (stripos($this->token, 'lp ') === 0) {
            $authHeader = 'Authorization';
        }

        try {
            $response = $this->client->post($this->keyUrl, [
                'headers' => [
                    $authHeader => $this->token,
                    'Content-Type' => 'application/json',
                ],
				'verify' => $this->certFile,
				'body' => json_encode(['label' => 'wordpress-plugin']),
            ]);
            
			$body = json_decode($response->getBody(), true);

            $value = false;
			if (array_key_exists('value', $body)) {
                $value = $body['value'];
			}

        } catch (ClientException $e) {
            // token is bad
            $value = false;

        } catch (ConnectException $e) {
            $value = false;
        }

        return $value;
    }
795775
public function setApiKey($apiKey)
    {
        $apiKey = trim($apiKey);

        if (!preg_match('/^(live|test)_\w{30,}$/', $apiKey)) {
            throw new ApiException("Invalid API key: '{$apiKey}'. An API key must start with 'test_' or 'live_' and must be at least 30 characters long.");
        }

        $this->apiKey = $apiKey;
        $this->oauthAccess = false;
        return $this;
    }
771970
public function create($params = array())
    {
        $arr = array(
            "bank_name" => $params["bank_name"],
            "branch_name" => $params["branch_name"],
            "bank_account_type" => $params["bank_account_type"],
            "number" => $params["number"],
            "name" => $params["name"]
        );
        $rawResponse = $this->client->request('post', 'api/bank_accounts', $arr);
        return $rawResponse;
    }
1060404
public function account()
    {
        $this->logger->debug("account: start");

        if (empty($this->access_key)) {
            throw new \Exception("access key not set");
        }

        $accountUrl = sprintf("%s/%s", $this->api_url, "account");
        $client = new \GuzzleHttp\Client();

        $result = $client->post($accountUrl, array(
            'multipart' => array(
                array(
                    'name' => 'accesskey',
                    'contents' => $this->access_key
                )
            ),
            'timeout' => $this->timeout
        ));

        $contents = $result->getBody()->getContents();
        $data = json_decode($contents, true);

        // check for non zero staus codes
        if (isset($data['flag']) && $data['flag'] > 0) {
            throw new \Exception($data['errortext']);
        }

        return $data;
    }
1246663
protected function getAuthorizationHeader()
    {
        if (empty($this->apiKeyHeader) || empty($this->apiKey)) {
            throw new \Exception('API key is not set.');
        }

        return [$this->apiKeyHeader => $this->apiKey];
    }
486926
def create_key(self, title, key):
        
        created = None

        if title and key:
            url = self._build_url('user', 'keys')
            req = self._post(url, data={'title': title, 'key': key})
            json = self._json(req, 201)
            if json:
                created = Key(json, self)
        return created
1034347
public function CreateEncrpytionKey()
	{
		if (function_exists('random_bytes'))
		{
			return base64_encode(random_bytes(32));
		}
		if (function_exists('openssl_random_pseudo_bytes'))
		{
			return base64_encode(openssl_random_pseudo_bytes(32));
		}
		throw new GrabzItException("Your installation of PHP does not support a method for making a cryptographically secure encryption key. Please upgrade to at least PHP 5.3", GrabzItException::GENERIC_ERROR);		
	}
836872
public function getAuthorizationBasic()
    {
        if ( ! empty($this->key) && ! empty($this->secret)) {
            $key = rawurlencode($this->key);
            $secret = rawurlencode($this->secret);

            return 'Basic ' . base64_encode($key . ':' . $secret);
        }

        return false;
    }
391144
public function create($data, $apiKeyId = null)
    {
        if (isset($apiKeyId)) {
            return $this->client()->put($data, 'api-keys/{apiKeyId}', ['apiKeyId' => $apiKeyId]);
        }

        return $this->client()->post($data, 'api-keys');
    }
751132
protected function _new_key()
	{
		$key = '';
		while (strlen($key) < 32)
		{
			$key .= mt_rand(0, mt_getrandmax());
		}
		return md5($this->config['cache_id'].'_'.uniqid($key, TRUE));
	}
785875
private function key_create()
    {
        $this->enigma->include_script('openpgp.min.js');

        $this->rc->output->add_handlers(array(
            'keyform' => array($this, 'tpl_key_create_form'),
        ));

        $this->rc->output->set_pagetitle($this->enigma->gettext('keygenerate'));
        $this->rc->output->send('enigma.keycreate');
    }
967842
def create_api_key(awsclient, api_name, api_key_name):
    
    _sleep()
    client_api = awsclient.get_client('apigateway')
    print('create api key: %s' % api_key_name)

    response = client_api.create_api_key(
        name=api_key_name,
        description='Created for ' + api_name,
        enabled=True
    )

    #print(json2table(response))

    print('Add this api key \'%s\' to your api.conf' % response['id'])
    return response['id']
164177
public function jsonSerialize()
    {
        $parameters = [];

        if ($this->accessToken) {
            $parameters['access_token'] = $this->accessToken;
        }

        if ($this->userId) {
            $parameters['user_id'] = $this->userId;
        }

        if ($this->entityId) {
            $parameters['entity_id'] = $this->entityId;
        }

        if ($this->expires) {
            $parameters['expires'] = $this->expires;
        }

        return $parameters;
    }
1050657
protected function setKeysForSave()
    {
        // Convert objects to array
        $params = array_map(function($value) {
            if (is_object($value)
                && !($value instanceof UploadedFile)
                && is_callable([$value, 'toApi'])) {
                return $value->toApi();
            }

            return $value;
        }, $this->toApi());

        // Remove dynamic params
        return array_except($params, array_merge([static::CREATED_AT, static::UPDATED_AT], [
            'id',
            'pagination',
        ]));
    }
296774
public function create($account = NULL, $params = array()) {
    if(is_string($account)) {
      $json = trim($account);
    } else if(is_array($account)) {
      $json = json_encode($account);
    } else {
      throw new Services_Zencoder_Exception(
        'Account parameters required to create account.');
    }
    return new Services_Zencoder_Account($this->proxy->createData("account", $json, $params));
  }
719686
private function getToken()
    {
        $vars = array(
            'method' => 'auth.getToken',
            'api_key' => $this->apiKey
        );

        $sig = $this->apiSig($this->apiSecret, $vars);
        $vars['api_sig'] = $sig;

        if ($call = $this->apiGetCall($vars)) {
            $this->token = $call->token;
        } else {
            return false;
        }
    }
215315
public function generateKey()
    {
        if (extension_loaded('openssl')) {
            $key = openssl_random_pseudo_bytes(16);
        } else {
            // SHA1 is 128 bit (= 16 bytes)
            $key = sha1(spl_object_hash($this) . mt_rand(0, PHP_INT_MAX) . uniqid('', true), true);
        }

        return base64_encode($key);
    }