A man who believed police officers were manhandling his friend and "treating him badly" admitted using threatening and abusive words and behaviour.
Simon McMinn needed two blasts of pepper spray to calm him down even though he had been handcuffed, magistrates were told.
Katy Varlow, prosecuting, told Skipton magistrates the 36-year-old became aggressive and squared up to police officers in Greatwood Avenue, Skipton, on April 22.
He refused to co-operate and became violent and when being put into the police vehicle, pushed his legs out to prevent the door being closed.
McMinn of Greatwood Avenue, Skipton, was sentenced to 12 months community service with a curfew between 8pm and 8am for eight weeks. He was told he must pay a £60 victims surcharge.
John Mewies, for McMinn, said he became upset when officers began searching his friend and was angry at the way he was being manhandled.
"He perceived they were mistreating his friend. He was quickly over-powered and handcuffed but he was still pepper sprayed twice," said Mr Mewies.