You are here

HttpClientBasicAuth.inc in Http Client 7.2

File

includes/auth/basic/HttpClientBasicAuth.inc
View source
<?php

class HttpClientBasicAuth implements HttpClientAuthentication {
  function __construct($username, $password = NULL) {
    $this->username = $username;
    $this->password = $password;
  }
  public function authenticate($request) {

    // Some API require only API-key with empty password.
    $request->options['curlopts'][CURLOPT_USERPWD] = !empty($this->password) ? "{$this->username}:{$this->password}" : $this->username;
  }

}

Classes