From what I've read, the courts have long held that in "exigent" or emergency situations that people's Fourth Amendment rights against illegal searches and seizures can be suspended.
Only if there exists probable cause that the person has committed a crime. They had none.
It was later adjudicated to allow a "stop and frisk" for weapons if the officer had reasonable suspicion that the person has committed, is committing, or is about to commit a crime and has a reasonable belief that the person may be armed and presently dangerous. But this was several years away, still. Terry v. Ohio, 392 U.S. 1 (1968)
However, they had no such reasonable suspicion towards a guy buying a coke in a second floor lunchroom.
This is clearly for me one of those instances. Was Baker supposed to get a search warrant? Stop and ask Oswald questions?
A cop can ask anybody whatever questions they like. It's free speech. Just not detain, search, or arrest them.