To expand on what Nugatory said, temperature is statistical. For example if I have one molecule it doesn't have a temperature, it has a kinetic energy. When we have lots of molecules we only say they have a temperature if their kinetic energy is distributed something similar to the distribution they would have at thermal equilibrium. They don't have to be at thermal equilibrium, but the distribution has to be thermal or close to thermal for us to label it with a temperature. The thermal distribution arises from how energy is shared among the molecules by random processes, and a thermal distribution allows us to reason by thermodynamics how that energy will be shared with another body in thermal contact again by random statistical processes. If the distribution isn't thermal, say all the molecules were shot out of an accelerator with a narrow distribution of energies, then if we try and associate the kinetic energy with a temperature and use thermodynamics to say what will happen when the molecules hit a target or the wall we will be wrong. The laws of thermodynamics and thermodynamic calculations are based on the idea that the kinetic energy is being randomly shared among the degrees of freedom.
Well light is the same. A stream of photons is said to have a temperature if it has a distribution (and with light that means spectrum or more precisely a distribution in spectral density) that is similar to the spectrum that would arise from random thermal processes, i.e. a blackbody spectrum. If it has that distribution we can use temperature and thermodynamic reasoning to say what will happen if that light impinges on an object i.e. we can say the light spectrum has a temperature. If it doesn't have that spectrum and we try to reason thermodynamically we will be wrong.