Having good luck with essential oil spray on a mowed-weed-style composting toilet. We separate urine off, so it's a very dry situation. I can't vouch for whether this would work in a full-mixture CT. Maybe because this has some oil in the spray it is held in place by the dry weeds. I ran across this researching eucalyptus oil for insect/mice repellent, but any essential oil mixture could be used. We also have not had any gnats since we've separated off the urine.
In a 4 oz. spray bottle choose among favorite essential oils such as (get 50 drops total):
I just wanted to add, I doubt that eucalyptus oil would keep flies away from a composting toilet. It's such a concentrated mass. I haven't tried layering the contents with eucalyptus leaves, but I still doubt it, particularly in the summer.