public function authenticateAsUser($username, $password, $tenantId = NULL, $tenantName = NULL) {
    $ops = array(
      'passwordCredentials' => array(
        'username' => $username,
        'password' => $password,
      ),
    );

    // If a tenant ID is provided, added it to the auth array.
    if (!empty($tenantId)) {
      $ops['tenantId'] = $tenantId;
    }
    elseif (!empty($tenantName)) {
      $ops['tenantName'] = $tenantName;
    }


    return $this->authenticate($ops);
  }