AnsweredAssumed Answered

IdentityManager, ServerInfo, CORS and tokenServiceUrl confusion

Question asked by deleted-user-VeZur_n9o0OZ on Mar 13, 2014
Latest reply on Apr 15, 2014 by deleted-user-VeZur_n9o0OZ
Hello all,

I'm working with the new Spatial Analysis Services. Specifically FindNearest at ""

When I submit my job to this url by clicking a button I'm prompted to login to AGOL by the IdentityManager. I'd like to either prompt for login when the app loads, or better yet just suppress the sign in all together and login with a developer account I've created.

Using IdentityManager and a ServerInfo object, I can prompt the user to login when the app loads. I then register the returned token with the IdentityManager. However, when I call my FindNearest function I get an error about access control allow origin and the request fails. My app is hosted locally. I've tried adding "" to to no avail.

XMLHttpRequest cannot load�?�OPERATOR%20LIKE%20%27%25%27%22%7D&maxCount=10&measurementType=StraightLine. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. I'm pretty sure is CORS enabled.

So I'm guessing my ServerInfo is not set up correctly and I'm not generating a valid token/credentials to access

   = true;
            // = "http://localhost/esriProxy/proxy.ashx?"
   = "http://localhost/esriProxy/";

            var server = new ServerInfo({
                server: "",
                tokenServiceUrl: ""
                // I saw the below on my
                //adminTokenServiceUrl: ""
            var loginDeferred ="", server);

            loginDeferred.then(function (response) {

$("#searchButton").click(function () {
var gp = new Geoprocessor("");
var params = //skipped for space but I know these are fine
gp.submitJob(params, completeCallback);


I've also tried using a proxy in the event that CORS isn't working but can't seem to crack that either. Still get the CORS error message.

<?xml version="1.0" encoding="utf-8" ?>
<ProxyConfig allowedReferers="*"
        <serverUrl url=""
  <serverUrl url=""

I'm doing at least one thing wrong...