One way I handle the police here in Australia, when im being harassed, is i let them carry on with their shit for a while thinking they're a tough guy/girl,
i will then camly ask them, "I will require your personal identification details as I feel that the current treatment and behaviour I am experiencing constitutes harassment, I think that this treatment is unnecessary and I think I will be making a formal complaint." Or something to that effect.... Important to be calm but to act offended and surprised by their terrible behaviour.
They also will normally ask what your occupation is about this time, I tell them I'm a biomedical scientist (because I am) but another one I've used is law student, anything intellectual will intimidate the small mind of the officer and make them worry even more when coupled to the complaint threat.
Another move is leave one cop out, only asking the tough guy/gal cop for their details insinuating that I am leaving the other cop out of the complaint, (normally only one cop is acting the main fuckhead) this will typically divide them, as the tough guy cop realises I'm an epic pain in the ass the non tough guy cop will step off completely knowing they are not getting shit on them at that time.
This has pretty much never failed me, I also think it works because if they follow through with their shit, car search, fine etc I will actually file the complaint, they can pick up that I'm not bluffing and I understand their bullshit system.