{"action":"created","issue":{"url":"https://api.github.com/repos/Esri/esri-leaflet/issues/590","labels_url":"https://api.github.com/repos/Esri/esri-leaflet/issues/590/labels{/name}","comments_url":"https://api.github.com/repos/Esri/esri-leaflet/issues/590/comments","events_url":"https://api.github.com/repos/Esri/esri-leaflet/issues/590/events","html_url":"https://github.com/Esri/esri-leaflet/issues/590","id":95246415,"number":590,"title":"Authentication request works in firefox but 500 error in chrome.","user":{"login":"SlwStdySqz","id":8496965,"avatar_url":"https://avatars.githubusercontent.com/u/8496965?v=3","gravatar_id":"","url":"https://api.github.com/users/SlwStdySqz","html_url":"https://github.com/SlwStdySqz","followers_url":"https://api.github.com/users/SlwStdySqz/followers","following_url":"https://api.github.com/users/SlwStdySqz/following{/other_user}","gists_url":"https://api.github.com/users/SlwStdySqz/gists{/gist_id}","starred_url":"https://api.github.com/users/SlwStdySqz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SlwStdySqz/subscriptions","organizations_url":"https://api.github.com/users/SlwStdySqz/orgs","repos_url":"https://api.github.com/users/SlwStdySqz/repos","events_url":"https://api.github.com/users/SlwStdySqz/events{/privacy}","received_events_url":"https://api.github.com/users/SlwStdySqz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-07-15T17:23:12Z","updated_at":"2015-07-15T17:38:19Z","closed_at":null,"body":"Hi,\r\nHopefully you guys can help me with some trouble I'm having with my map authentication. Working off of a modified form of the [example](http://esri.github.io/esri-leaflet/examples/arcgis-server-auth.html) in the documentation, I can successfully authenticate and get a valid token in firefox. However the same code returns a 500 error in chrome. \r\n\r\n```javascript\r\n//make login box\r\nfunction makeLoginBox() {\r\n  var loginDiv = document.createElement('div');\r\n  loginDiv.id = 'loginbox';\r\n  loginDiv.innerHTML = \"<center><b>Login</b></center><form id=\\\"l-form\\\" name=\\\"login-form\\\">Username<br><input name=\\\"username\\\"/><br>Password<br><input name=\\\"password\\\" type=\\\"password\\\"/><br><input type=\\\"submit\\\" id=\\\"login-btn\\\" value=\\\"login\\\"/></form>\"; \r\n  var mapDiv = document.getElementById('map'); \r\n  document.body.insertBefore(loginDiv, mapDiv);\r\n  };\r\nmakeLoginBox() //insert into DOM\r\n\r\n//retrieve credentials\r\nfunction getCredentials() {\r\n  var x = document.getElementById('l-form');\r\n  var authN = x.elements[0].value;\r\n  var authP = x.elements[1].value;\r\n  return [authN, authP]\r\n  };\r\n\r\n//validate supplied credentials & load app if valid\r\nfunction validateCred(){\r\n  var cred = getCredentials();\r\n  if (cred[0].length === 0 || cred[1].length === 0) {\r\n    alert(\"Username and Password are required!\");\r\n    }\r\n  else {\r\n    //remove loginbox if credentials valid\r\n    var body = document.getElementsByTagName('body');\r\n    var loginbox = document.getElementById('loginbox');\r\n    body[0].removeChild(loginbox);\r\n    //add credentials to server request\r\n    function serverAuth (callback) {\r\n      L.esri.post('http://sampleserver6.arcgisonline.com/arcgis/tokens/generateToken', {\r\n        username: cred[0],\r\n        password: cred[1],\r\n        f: 'json',\r\n        expiration: 6, //minutes\r\n        client: 'referer',\r\n        referer: window.location.origin},\r\n        callback);\r\n      };\r\n    //send request\r\n    serverAuth(function (error, response) {\r\n      console.log(error);\r\n      console.log(response);\r\n    });\r\n  }\r\n}\r\n//attached validate function to login button\r\nvar loginSubmit = document.getElementById(\"login-btn\");\r\nloginSubmit.onclick = validateCred;\r\n```\r\nMy results in chrome:\r\n```\r\nObject {code: 500, message: \"Could not parse response as JSON. This could also be caused by a CORS or XMLHttpRequest error.\"}\r\n```\r\nIn firefox:\r\n```\r\nObject { token: \"-4R2m_dw_zarm4pGQ0yYIltZFkb7PeQN8u1…\", expires: 1436981012163 }\r\n```"},"comment":{"url":"https://api.github.com/repos/Esri/esri-leaflet/issues/comments/121688784","html_url":"https://github.com/Esri/esri-leaflet/issues/590#issuecomment-121688784","issue_url":"https://api.github.com/repos/Esri/esri-leaflet/issues/590","id":121688784,"user":{"login":"jgravois","id":3011734,"avatar_url":"https://avatars.githubusercontent.com/u/3011734?v=3","gravatar_id":"","url":"https://api.github.com/users/jgravois","html_url":"https://github.com/jgravois","followers_url":"https://api.github.com/users/jgravois/followers","following_url":"https://api.github.com/users/jgravois/following{/other_user}","gists_url":"https://api.github.com/users/jgravois/gists{/gist_id}","starred_url":"https://api.github.com/users/jgravois/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jgravois/subscriptions","organizations_url":"https://api.github.com/users/jgravois/orgs","repos_url":"https://api.github.com/users/jgravois/repos","events_url":"https://api.github.com/users/jgravois/events{/privacy}","received_events_url":"https://api.github.com/users/jgravois/received_events","type":"User","site_admin":false},"created_at":"2015-07-15T17:38:19Z","updated_at":"2015-07-15T17:38:19Z","body":"can you reproduce with something as simple as [this](https://dl.dropboxusercontent.com/u/59331579/js/token.html)?\r\n```js\r\nL.esri.post('//sampleserver6.arcgisonline.com/arcgis/tokens/generateToken', {\r\n    username: 'user1',\r\n    password: 'user1',\r\n    f: 'json',\r\n    expiration: 6, //minutes\r\n    client: 'referer',\r\n    referer: window.location.origin\r\n},\r\nmyCallback);\r\n\r\nfunction myCallback(error, response){\r\n    document.write('error: ' + error + '<br>');\r\n    document.write('token: ' + response.token);\r\n};\r\n```"}}