795
Don’t ever hand your phone to the cops
(www.theverge.com)
This is a most excellent place for technology news and articles.
The litmus test for whether something is a lawful order is to ask what will happen if you refuse. If the penalty for refusal is your arrest, say that you would prefer not to but will comply under threat of arrest. If it actually wasn't a lawful order but you complied to avoid arrest, you'll learn from a lawyer and get to sue over that.
As somebody else noted, driving is a privilege, not a right; if you're pulled over for a traffic offense, you're obligated to hand over your license and other related documents as requested depending on the state, probably registration and proof of insurance. If you don't, then in many states it's assumed that you were driving without being licensed to do so, and you're probably going to jail.
On the flip side, if the cop asks to search your vehicle, you can tell him no. Don't stop him from doing it anyway, just reiterate that you don't consent to it and fight in court. There are some situations (like you're under arrest and your car is being inventoried and impounded) in which they don't need your consent to get in your car. Probable cause also gets them access to your car without your consent.
If you're asked to do a field sobriety test, just refuse. Same for a breathalyzer. They'll probably take you in and have you use a lab machine at the station, but that's preferable to their bullshit games if you know you're not doing anything wrong. Make quantitative science be the only evidence. Don't drink and drive in the first place and you'll be fine on that front.