In my application I already have an api token (retrieved it using rest call). Now I want to use this token to load layers.
When I load FeatureLayer everything works just fine (FeatureLayer has apiKey parameter documented). Both layer and legend loads without problems.
When i try to load MapImageLayer (this layer does not have apiKey), the layer itself load just fine but the legend call does not use provided token and causes to login form pop up. After cancelling login form I have following warning in console:

How to properly provide apiKey to MapImageLayer? I already tried
- appending token parameter to url
- adding apiKey in esriConfig
without success.