Demo of how the loadTilesWithAjax and ajaxHeaders options as well as the getTileHeaders() method on TileSource can be applied.
Examine the network requests in your browser developer tools to see the custom headers sent with each request.