The city was aware of what he was doing as an agent of the city.
The city cannot authorize an agent to do what they have no power to do. They cannot distribute controlled substances, and they cannot authorize an agent to do it either.
To do so is called "acting under color of law" and is not permitted.