I had a situation 15-20 years ago while getting gas at night, a cruiser pulls up behind me and an officer jumps out accusing me of reckless driving. He then grabs the keys out of my hand and searches my vehicle, finding nothing. I received a ticket for something else, and after 1 year and going though the appeals process had the ticket thrown out by a 2nd judge.
If the officer is intent on searching your vehicle there isn't much you can do. I brought it up during the citation hearing with the 1st judge replying "there's a war on drugs, you do support the war on drugs?". There's only so much arguing you can do in a day.