Set email and password for Email:Password authentication.
@param string $apikey
@return Credentials
770446
public function setApiKey($apikey)
    {
        if (isset($this->emailPassword)) {
            throw new \Exception(
                "EmailPassword already set."
            );
		}
		$this->apikey = $apikey . ':';
		return $this;
    }
743015
public static function login($key, $email, $password)
    {
        $params = [
            "username" => $email,
            "password" => $password,
        ];

        $headers = [
            'W-Key' => $key
        ];

        $login = new static();
        $response = $login->makeRequest("login", self::METHOD_POST, $params, $headers);

        return $response;
    }
1194212
public static function authenticate(
        string $message,
        AuthenticationKey $secretKey,
        $encoding = Halite::ENCODE_BASE64URLSAFE
    ): string {
        $config = SymmetricConfig::getConfig(
            Halite::HALITE_VERSION,
            'auth'
        );
        /** @var string $mac */
        $mac = self::calculateMAC(
            $message,
            $secretKey->getRawKeyMaterial(),
            $config
        );
        $encoder = Halite::chooseEncoder($encoding);
        if ($encoder) {
            return (string) $encoder($mac);
        }
        return (string) $mac;
    }
507562
public function authenticate($apiKey, $apiSecret)
    {
        $this->auth[0] = $apiKey;
        $this->auth[1] = $apiSecret;

        return $this;
    }
822142
public function getCredential($key)
    {
        return !isset($this->credentials[$key]) ? null : $this->credentials[$key];
    }
1059949
protected function authenticate($key, $secret) {
		$token = $this->cache->get('Twitter_Application_Bearer_Token');
		if ($token === FALSE) {
			$bearerTokenCredentials = base64_encode(urlencode($key) . ':' . urlencode($secret));

			$uri = new Uri('https://api.twitter.com/oauth2/token');
			$httpRequest = Request::create($uri, 'POST');
			$httpRequest->setContent(http_build_query(array('grant_type' => 'client_credentials')));
			$httpRequest->setHeader('Authorization', 'Basic ' . $bearerTokenCredentials);
			$httpRequest->setHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');

			$response = $this->requestEngine->sendRequest($httpRequest);
			$authenticationReponseBody = json_decode($response->getContent(), TRUE);
			if (!isset($authenticationReponseBody['token_type']) || $authenticationReponseBody['token_type'] !== 'bearer' || !isset($authenticationReponseBody['access_token'])) {
				throw new \Exception('Invalid authentication answer! Your application could not authenticate with Twitter.', 1424698337);
			}

			$token = $authenticationReponseBody['access_token'];
			$this->cache->set('Twitter_Application_Bearer_Token', $token);
		}

		return $token;
	}
219363
def set_basic_auth(self, username, password):
        """"""
        credentials = str(b64encode('{}:{}'.format(username, password).encode('utf-8')), 'utf-8')
        self.authorization = 'Basic {}'.format(credentials)
759493
public function setPassword($password)
    {
        try {
            $this->getSoapClient()->SetDocumentPassword(array(
                'password' => $password ,
            ));

            return $this;
        } catch ( SoapException $ex ) {
            throw new PasswordException('Error while setting a password for the document' , $ex);
        }
    }
633755
public function login($username, $password, $scope = 'user_info')
	{
		$response = $this->http->post($this->getUrl('oauth/token'), array(
			'grant_type'	=>	'password',
			'username'		=>	$username,
			'password'		=>	$password,
			'client_id'		=>	$this->appid,
			'client_secret'	=>	$this->appSecret,
			'scope'			=>	$scope,
		));
		$this->result = $response->json(true);
		if(!isset($this->result['error']))
		{
			return $this->accessToken = $this->result['access_token'];
		}
		else
		{
			throw new ApiException(isset($this->result['error_description']) ? $this->result['error_description'] : '', $response->httpCode());
		}
	}
651113
public static function setKey($key, ClientInterface $client = null)
	{
		self::$api = new Api($key, $client);

		return self::$api;
	}
578033
public function sendRequest(ApiKey $apiKey, RestRequest $request)
    {
        $hmac = $this->generateHmac($apiKey->getPrivateKey(), $request->getEndpoint(), array_merge($request->getQueryData(), $request->getPostData()));

        $client = new Client([
            'base_uri' => $request->getHost()
        ]);
        
        $args = [
            'auth' => [$apiKey->getPublicKey(), $hmac],
            'headers' => [
                'Accept' => 'application/json'
            ]
        ];
        
        if ($request->getRequestMethod() === 'POST') {
            $args['form_params'] = $request->getPostData();
        } else {
            $args['query'] = $request->getQueryData();
        }
        
        try {
            $responseRaw = $client->request($request->getRequestMethod(), $request->getEndpoint(), $args);
        } catch (RequestException $e) {
            if (!$e->hasResponse()) {
                throw new Exception('Cannot send REST request.', 0, $e);
            }
            
            $responseRaw = $e->getResponse();
        }
        
        return $this->prepareResponse($responseRaw, $request);
    }
412160
public function setCredentials($username, $password)
    {
        $this->username = $username;
        $this->password = $password;
        $this->token = '';
        $this->accessToken = '';
        return $this;
    }
189630
public function authenticateUser($email, $password) 
    {
        if (empty($this->config->getBearer())) {
            $this->getAccessToken();
        }
        // @todo validate email address and password
        $options = $this->config->getUserAuthenticationConfiguration(
            $email,
            $password
        );
        // @todo test, returns the bearer if success
        $token = $this->getResponse('/oauth/token', $options);
        $this->config->setBearer($token['access_token']);
        return $token;
    }
1328434
public function login($login, $api_key)
    {
        if (empty($login) || !is_string($login)) {
            throw new \InvalidArgumentException('Argument "login" cannot be empty and must be a string');
        }

        if (empty($login) || !is_string($api_key)) {
            throw new \InvalidArgumentException('Argument "api_key" cannot be empty and must be a string');
        }

        $this->auth = [
            'login'         => $login,
            'password_hash' => $api_key,
        ];
    }
884744
public static function generateSignature($apiUser, $apiKey)
    {
        $serverTimezone = date_default_timezone_get();
        date_default_timezone_set('UTC');

        $nonce = self::generateNonce(self::NONCE_LENGTH);
        $time = time();
        $signature = hash_hmac('sha1', $apiUser . $nonce . $time, $apiKey);

        $data = [
            'REB-APIUSER' => $apiUser,
            'REB-NONCE' => $nonce,
            'REB-TIMESTAMP' => $time,
            'REB-SIGNATURE' => $signature,
        ];

        date_default_timezone_set($serverTimezone);

        return base64_encode(json_encode($data));
    }
495447
public function saveApiCreds($apiUser, $apiPass)
    {
        $this->helper->saveConfigData(
            Config::XML_PATH_CONNECTOR_API_ENABLED,
            '1',
            'default',
            0
        );
        $this->helper->saveConfigData(
            Config::XML_PATH_CONNECTOR_API_USERNAME,
            $apiUser,
            'default',
            0
        );

        //Save encrypted password
        $this->helper->saveConfigData(
            Config::XML_PATH_CONNECTOR_API_PASSWORD,
            $this->helper->encryptor->encrypt($apiPass),
            'default',
            0
        );

        //Clear config cache
        $this->config->reinit();

        return true;
    }
550783
public function setAuthentication(array $credentials): AbstractClientBuilder
    {
        if (array_key_exists('session_id', $credentials)) {
            $this->authentication = new HeaderAuthenticate($credentials['session_id']);
        } elseif (array_key_exists('username', $credentials) && array_key_exists('password', $credentials)) {
            $this->authentication = new HeaderLogin($credentials['username'], $credentials['password']);
        } else {
            throw new \InvalidArgumentException('No credentials given.');
        }

        return $this;
    }