Catalog service RequiresTokens method

Indicates if a token service has been enabled on an ArcGIS Server site.


Return Value

A boolean indicating the ArcGIS Server site requires a token (true) or not (false).


If services on an ArcGIS Server site require authentication, authentication may be managed using a token service.



Catalog catalog = new Catalog();

catalog.Url = "http://localhost:6080/arcgis/services";


MapService_MapServer mapservice = new MapService_MapServer();

mapservice.Url = "http://localhost:6080/arcgis/services/MapService/MapServer";

if (catalog.RequiresTokens()


      string tokenurl = catalog.GetTokenServiceURL();

      string tokenrequesturl = tokenurl + "?request=getToken&username=myuser&password=secret";


      System.Net.WebRequest request = System.Net.WebRequest.Create(tokenrequesturl);

      System.Net.WebResponse response = request.GetResponse();

      System.IO.Stream responseStream = response.GetResponseStream();

      System.IO.StreamReader readStream = new System.IO.StreamReader(responseStream);

      string myToken = readStream.ReadToEnd();
      mapservice.Url = mapservice.Url + "?token=" + myToken;



string mapname = mapservice.GetDefaultMapName();


Dim catalog As Catalog = New Catalog()

catalog.Url = "http://localhost:6080/arcgis/services"


Dim mapservice As MapService_MapServer = New MapService_MapServer()

mapservice.Url = "http://localhost:6080/arcgis/services/MapService/MapServer"


If catalog.RequiresTokens() Then

      Dim tokenurl As String = catalog.GetTokenServiceURL()

      Dim tokenrequesturl As String = tokenurl + "?request=getToken&username=myuser&password=secret"

      Dim request As System.Net.WebRequest = System.Net.WebRequest.Create(tokenrequesturl)

      Dim response As System.Net.WebResponse = request.GetResponse()

      Dim responseStream As System.IO.Stream = response.GetResponseStream()

      Dim readStream As System.IO.StreamReader = New System.IO.StreamReader(responseStream)

      Dim myToken As String = readStream.ReadToEnd()

      mapservice.Url = mapservice.Url + "?token=" + myToken

End If


Dim mapname As String = mapservice.GetDefaultMapName()


String serviceURL = "http://localhost:6080/arcgis/services";

ServiceCatalogBindingStub serviceCatalog = new ServiceCatalogBindingStub(serviceURL);

System.out.println ("requiresTokens: " + serviceCatalog.requiresTokens());