In this reaction, glucose (an aldehyde) in an alkaline solution is slowly oxidized by dioxygen to form gluconic acid:
CH2OHCHOHCHOHCHOHCHOHCHO + 1/2 O2 --> CH2OHCHOHCHOHCHOHCHOHCOOH
Gluconic acid is converted to sodium gluconate in the presence of sodium hydroxide. Methylene blue speeds up this reaction by acting as an oxygen transfer agent. By oxidizing glucose, methylene blue is itself reduced (forming leucomethylene blue), and becomes colorless.
If there is a sufficient available oxygen (from air), leucomethylene blue is re-oxidized and the blue color of solution can be restored. Upon standing, glucose reduces the methylene blue dye and the color of the solution disappears. In dilute solutions the reaction takes place at 40-60°C, or at room temperature (described here) for more concentrated solutions.

