{"action":"closed","issue":{"url":"https://api.github.com/repos/Esri/esri-leaflet/issues/807","repository_url":"https://api.github.com/repos/Esri/esri-leaflet","labels_url":"https://api.github.com/repos/Esri/esri-leaflet/issues/807/labels{/name}","comments_url":"https://api.github.com/repos/Esri/esri-leaflet/issues/807/comments","events_url":"https://api.github.com/repos/Esri/esri-leaflet/issues/807/events","html_url":"https://github.com/Esri/esri-leaflet/issues/807","id":167936904,"number":807,"title":"ImageLayer Token Authentication","user":{"login":"alexpatow","id":4375082,"avatar_url":"https://avatars.githubusercontent.com/u/4375082?v=3","gravatar_id":"","url":"https://api.github.com/users/alexpatow","html_url":"https://github.com/alexpatow","followers_url":"https://api.github.com/users/alexpatow/followers","following_url":"https://api.github.com/users/alexpatow/following{/other_user}","gists_url":"https://api.github.com/users/alexpatow/gists{/gist_id}","starred_url":"https://api.github.com/users/alexpatow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexpatow/subscriptions","organizations_url":"https://api.github.com/users/alexpatow/orgs","repos_url":"https://api.github.com/users/alexpatow/repos","events_url":"https://api.github.com/users/alexpatow/events{/privacy}","received_events_url":"https://api.github.com/users/alexpatow/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-07-27T19:33:24Z","updated_at":"2016-08-01T19:39:27Z","closed_at":"2016-08-01T19:39:27Z","body":"Hi All,\r\n\r\nFor a project I'm working on I needed to authenticate an ImageService using esri-leaflet. I have code to fix this issue if the maintainers would like a pull request (see below).\r\n\r\n* Browser and version:\r\n\r\nChrome 51/52, Safari 9.1.2\r\n\r\n* Version of Leaflet (`L.version`):\r\n\r\n0.7.7, 1.0.0-rc.1, 1.0.0-rc.2\r\n\r\n* Version of esri Leaflet (`L.esri.VERSION`):\r\n\r\n1.0.3, 2.0.1\r\n\r\nSteps to reproduce the error:\r\n\r\n1) Create a new html file with the contents of: http://esri.github.io/esri-leaflet/examples/arcgis-server-auth.html\r\n\r\n2) Replace L.esri.dynamicMapLayer with L.esri.imageMapLayer\r\n\r\n3) Replace URLs and Username/Password with your server and credentials\r\n\r\n4) Open file in browser\r\n\r\nWhat happens is:\r\n\r\n1)  Browser gets token correctly (200 status)\r\n\r\n2) Browser performs GET call to the service's \"?exportImage\" endpoint with token, bounding box, format, and other parameters\r\n\r\n3) Browser receives an object with href, width, height, extent, and scale properties\r\n\r\n3) Browser attempts to get the .png image using the href string in the previous response, but it returns a 499 error (Token Required)\r\n\r\nI was expecting the service to return the image for leaflet to display.\r\n\r\nI'd be happy to make a plunkr if you have an Image Service with public credentials.\r\n\r\nI've tried with both CDN and [browserify](http://browserify.org/)\r\n\r\n\r\n*Fix:*\r\n\r\nI discovered that appending the token to the \"href\" returned by the image service will correctly return the image.\r\n\r\nAdding:\r\nif (this.options.token) {\r\n  response.href += ('?token=' + this.options.token);\r\n}\r\n\r\nAfter:\r\nif (error) { return; }\r\n\r\nin src/Layers/ImageMapLayer.js seems to work.\r\n\r\nThanks,\r\n\r\nAlex\r\n\r\n"}}
{"actor":{"display_login":"jgravois"}}