This method was added in 0.12.7, but does not appear to work when called from triggers or scheduler jobs, but does from menu items. The difference appears to be whether you have a Context (works) or TriggerContext/JobContext (fails).
The error message reads "Error: 16 UNAUTHENTICATED: username not found in request context".