public function create_token($password, $valueToStore=null, $tokenId=null, $lifetime=null, $maxUses=null, $tokenType=0, $uid=0) {
		
		if(is_null($tokenId) || strlen($tokenId) < 1) {
			$tokenId = $this->generate_token_string();
		}
		
		
		$finalHash = password_hash($password, $this->passAlgorithm);
		
		if(!is_numeric($tokenType)) {
			$tokenType = $this->lookup_token_type($tokenType);
		}
		
		$insertData = array(
			'auth_token_id'	=> $tokenId,
			'passwd'		=> $finalHash,
			'stored_value'	=> serialize($valueToStore),
			'token_type_id'	=> $tokenType,
			'uid'			=> $uid,
		);
		
		if(!is_null($maxUses) && is_numeric($maxUses)) {
			$insertData['max_uses'] = $maxUses;
		}
		try {
			$fields = "";
			$values = "";
			foreach($insertData as $k=>$v) {
				$fields = ToolBox::create_list($fields, $k);
				$values = ToolBox::create_list($values, ':'. $k);
			}
			
			if(!is_null($lifetime) && strlen($lifetime) > 0) {
				$fields .= ", expiration";
				$values .= ", NOW() + :life::interval";
				$insertData['life'] = $lifetime;
			}
			
			$sql = "INSERT INTO cswal_auth_token_table (". $fields .") VALUES (". $values .")";
			
			$numRows = $this->db->run_query($sql, $insertData);
			
			if($numRows != 1) {
				throw new LogicException(__METHOD__ .": unable to create token (". $numRows .")");
			}
		}
		catch(exception $e) {
			if(preg_match('/duplicate key value violates unique constraint/', $e->getMessage())) {
				throw new ErrorException(__METHOD__ .": attempt to create non-unique token (". $tokenId .")");
			}
			else {
				throw new ErrorException(__METHOD__ .": failed to create token::: ". $e->getMessage());
			}
		}
		
		return($tokenId);
	}