If evidence is taken from your vehicle in violation of the 4th Amendment’s protections, the government cannot later use that evidence to obtain your conviction. The starting point in dealing with seized evidence is always the existence or absence of a warrant. Warrantless searches are unconstitutional and correspondingly illegal. If evidence is taken as the result of an unconstitutional search, the government must prove an exception to the warrant requirement applies, or it will be unable to use the evidence, no matter how incriminating.
A time-honored exception to the warrant requirement is when someone, with authority, gives permission to law enforcement to search their vehicle.
Of course, consent may be given to search other areas; one’s person, one’s home, or one's business. In order for valid consent to be given, all of the surrounding circumstances must indicate the person giving consent did so voluntarily, and free of any intimidation or coercion. The individual giving consent to the search many also limit the permission, and law enforcement is bound by any limitation. The search must end if the consenter revokes his or her permission. The government must prove to the court any consent was voluntary.
You do not have to allow law enforcement officers to search your vehicle.
Police cannot compel you to agree to a search. Their only option- unless some other exception applies- is to get a search warrant. That does not mean that police might not suggest otherwise, and knowingly or unknowingly exhibit such intimidation or coercion upon an individual that any permission given may be deemed involuntarily given. Consent given involuntarily is of no use to the government. It is invalid, and any evidence taken as a result of coerced consent cannot later be used at trial. The voluntariness of an alleged consent is a complex, are entirely fact dependent issues, often litigated by experienced criminal defense attorneys.