token

2870
4
10-19-2015 09:53 PM
jayasudha
New Contributor III

HI


I am trying to use token based authentication for services on ArcGIS server. I think short duration token is good for the user that consume service on website as this is going to be on public IP and open to all. Please advice.

What should be entered in HTTP referer: text box ? is thais map service URL ?

The default setting in ArcGIS server is 60 min for short and 1 day for long duration tokens. If i generate token using ArcGIS server (http://domain:6080/arcgis/admin/generateToken), it asks again to enter expiration in minutes instead of asking short or long duration, why ?

If i enter 30 min for token, it expires after 30min. How the public user can access this service over internet when token is expired ?

0 Kudos
4 Replies
RichardsonAluvilayil2
New Contributor III

Hello Jaya,

I think this will not answer your questions completely, but should make things more clear.

Parameter

Description

username

The name of an administrative account for the site.

password

The credentials of the administrative account.

client

The client IP or HTTP Referer to which the generated token will be bound.

Values: referer | ip | requestip

  • If the value is referer, the referer parameter must be specified.
  • If the value is ip, the ip parameter must be specified.
  • If the value is requestip, the IP address from where the request originated is used.
referer

The base URL of the web application that will invoke the Administrator API. This parameter must be specified if the value of client parameter is referer.

Example: referer=http://myserver/mywebapp

ip

The IP address of the machine that will invoke the Administrator API. This parameter must be specified if the value of the client parameter is ip.

Example: ##.##.###.###

expiration

The time in minutes for which the token must be valid.

f

The response format. The default response format is html.

Values: html | json

Please refer to the API Reference from the Generate Token page:

http://<your_server_machine_name>:6080/arcgis/admin/www/doc/index.html#/Generate_Token/02w00000005p000000/ 

Hope this helps.

Regards,

Richardson

zhongrenGu
New Contributor III

<script>

   var params={

  username:'arcgis',

  password:'arcgis',

  client:"referer",

  ip:"",

  referer:'http://'+window.location.host+'/',

  expiration:60,

  f:"pjson"
   };

  $.ajax({

  type:"post",

  url:"http://localhost:6080/arcgis/admin/generateToken",

  data:params,

  cache:true,

  dataType:"json",

  crossDomain: true,

  ContentType:'application/x-www-form-urlencoded',

   success:function(data){

  console.log(data);

  document.cookie="token="+escape(data.token);

  },

   error:function(){

  console.log("error");

  }

  });

</script>

-------------------------------------------------------------------------------

above,  this is my script to generate token, but in my broser,it's display ,

at the same times,i use it to generate token of Portal for ArcGIS  is correct   ,   can you help me ?

0 Kudos
zhongrenGu
New Contributor III

1、used proxy:

<script>

   var params={

  username:'arcgis',

  password:'arcgis',

  client:"referer",

  ip:"",

  referer:'http://'+window.location.host+'/',

  expiration:60,

  f:"pjson"
   };

  $.ajax({

  type:"post",

  url:"App/proxy/proxy.ashx?http://localhost:6080/arcgis/admin/generateToken",

  data:params,

  cache:true,

  dataType:"json",

  crossDomain: true,

  ContentType:'application/x-www-form-urlencoded',

   success:function(data){

  console.log(data);

  document.cookie="token="+escape(data.token);

  },

   error:function(){

  console.log("error");

  }

  });

</script>

2、jsonp:

var params={

  username:'arcgis',

  password:'arcgis',

  client:"referer",

  ip:"",

  referer:'http://'+window.location.host+'/',

  expiration:60,

  f:"pjson"
   };

$.get('http://localhost:6080/arcgis/admin/generateToken?callback=?',params,

function(data){

  console.log(data);

},'jsonp')

Console result:  it has no token

0 Kudos
zhongrenGu
New Contributor III