Is it ok to put a plug on a light fitting?
Well, there is "safe" and then there is "safe and legal".  Running what amounts to an extension cord up the wall to a light meant to be hard wired is going to be a code violation and there are subtle safety issues.

As far as "will this work and not kill me", then probably.  The cord needs to be fastened to the wall so no one trips on it or snags it with their hands or something they are carrying.  The connections at the light need to be done properly and fastened securely so the wire can't be puled out.

Would I do this in the living room with kids and visitors?  No, not at all.  But if this is just to get some light in the garage until a real light can be installed?  Sure, but make sure everything is very secure.  The real reason this is dangerous is mostly the cord getting damaged or pulled or having the light fall on your head.