The Mg ribbon ignites and burns with a bright white flame.
2 Mg (s) + O2 (g) ---> 2 MgO (s)
Mg (s) + N2 (g) ---> Mg3N2 (s) (The Mg ribbon reacts with both the oxygen and the nitrogen in the air.)
Oxygen is highly electronegative. It acts as an oxidizing agent for most substances with which it reacts. The oxygen oxidizes the magnesium ribbon to form the magnesium oxide salt.
The fact that the magnesium also undergoes oxidation with respect to nitrogen only attests to the magnesium's reactivity, not to any property of oxygen.
An NSF funded Project