This works great with esri.layers.ArcGISDynamicMapServiceLayer() and esri.tasks.FindTask(), but I'm unable to find a workaround for esri.tasks.QueryTask(). It appears that I have to use the single layer url for QueryTask, which seems to be a problem when using tokens (see first example):