Police in western New York have charged a man they say impersonated a police officer in an attempt to get discounted coffee.

WIVB-TV reports the man flashed a fake badge and gun at a Starbucks in Buffalo around 11pm Friday. Police say the man claimed he was a detective and asked for a discount.

Authorities say the man then left Starbucks and tried to get into Spot Coffee after closing time by claiming he was a police officer. He was later arrested.

Police say the man was carrying a BB gun.

Police have charged the 48-year-old Buffalo man with criminal trespassing, criminal impersonation of a police officer and menacing.

