I believe that you were correct in standing up for your rights.
I was a cop for 15 years, and I have told my wife ... cops don't come in the house, you don't answer questions, you don't allow them to 'look' in your car ....
99% of all cops are honest, and obey the laws they enforce ... but there are dirty cops out there .... ones that will drop a baggie of weed under your seat - only to 'find' it and say "Well - Look what I found ....." then they will say that they will let that young lady off the hook - for some oral sex.
Extreme? Sure! Rare ?!? You bet! But there are cops out there that will do it.
I know because I've seen cops charged for doing $hit like that! Gives all cops a bad name and they deserve whatever punishment they get ....
The worst part about dirty cops? They look just like all the other cops (who aren't dirty)!
So - that being said .... the answer to most encounters with the police has to be, "I'm sorry, I don't answer questions." "I'm sorry, I don't consent to searches of my person or vehicle." "Am I free to go?" "Am I being detained?"
Oh - one more thing - there is a difference between 'identifying yourself' and providing or showing an ID. In many cases, and in many states, there is no requirement to carry and provide a photo ID - even if you are required to 'identify yourself'. So - in many cases, unless you are driving, and you are required to identify yourself, simply tell the officer your name and DOB and let them run the information.
Luckily we don't live in a society where the 'authorities' can stop you and demand, "Papers please!" (yet)