AnsweredAssumed Answered

Arcgis Online Secure service vs Arcgis server secure service token

Question asked by bridgji on Feb 1, 2016

I am wokring on an app that I'm updating to use Secure Services. If I'm running from a map on my Arcgis server I can retrive a token and generate the map and everything runs fine. If I let he sign in popup come up I login with the userid /password it works fine.  If i run against the map with it published as public it works fine.  If I run against a map on Arcgis Online I can get a token but I my map never returns.  If i run against the map with it published as public it works fine.  I assume the issue is with the token or how i'm creating the map. I've tried adding a referer ip and tried using the RquestIP.


I'm getting the token with the following :




            if (tokenUrl != "")
                var data = new NameValueCollection();
                //data["client_id"] = username;
                //data["client_secret"] = password;
                data["username"] = username;
                data["password"] = password;
                data["expires"] = "2440";
                data["f"] = "json";
                JavaScriptSerializer jserialize = new JavaScriptSerializer();
                TokenInfo x = jserialize.Deserialize<TokenInfo>(_getResponse(data, tokenUrl));
                myToken = x.token;
                var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                var expire = epoch.AddMilliseconds(x.expires).ToLocalTime();

                dictionary.Add("token", myToken);

                return dictionary;
                return dictionary;
        public class TokenInfo
            public string token { get; set; }
            public long expires { get; set; }
            public bool ssl { get; set; }
        private string _getResponse(NameValueCollection data, string url)
            string responseData;
            var webClient = new WebClient();
            var response = webClient.UploadValues(url, data);
            responseData = System.Text.Encoding.UTF8.GetString(response);



I do get a token value back.

I'm creating the map through

configOptions = {
                    webmap: arcgisID,
                    title: "",
                    subtitle: "",
                    sharingurl: ""

   arcgisUtils.createMap(configOptions, "map").then(function (response) {


I do have it set to go through the proxy page where it should be handling adding the token. When I run this against the sercure services on my local arcgis server it does work .


I did try registering the token before this call but it didn't help.

                var tokenOptions = {
                    expires: 1454341793222,
                    ssl: true,
                    token: "6p-T1f4xsDozwO9mvGgeN_f8h89u2yeK5FsJPEo-1cRS6IWtwV5XjWofswW6_dAkJ1XNRVHF-7bWbNDqL70z_hyzZF4Dx3BxXbM0uELElCFjz5ikOSAjCCZA0Fm7JAUO6sjy7dg7ogLQThsqjEniIQ..",
                    userid: "myuserid"
                EsriId.registerToken(tokenOptions); (response) {



I've been assuming that the  referer information I'm providing is wrong but at this point I'm not sure.