Thanks @BlakeTerhune for the reply.
- Is there any other way apart from application authentication if I don't want to get credentials from each users?
- I changed my code and now generating the Token in the code like below and CORS is the challenge I'm facing now. Any suggestion?:-
<script>
function getToken() {
var settings = {
"url": "https://token.slip.wa.gov.au/arcgis/tokens/generateToken",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/x-www-form-urlencoded"
},
"data": {
"username": "username@domain.com",
"password": "678965",
"client": "referer",
"ip": "",
"referer": "https://www.domain.com/",
"expiration": "60",
"f": "json"
},
async: false
};
return $.ajax(settings).done().responseText;
}
console.log('1');
var result = getToken();
var token1 = $.parseJSON(result).token;
require(["esri/config", "esri/Map", "esri/views/MapView", "esri/layers/FeatureLayer"], function (esriConfig, Map, MapView, FeatureLayer) {
esriConfig.apiKey = "AAPK9c1060b46848481f85233a3e-_hEZz";
const map = new Map({
basemap: "arcgis-topographic" // Basemap layer service
});
const view = new MapView({
map: map,
center: [115.860299, -31.954594], // Longitude, latitude
zoom: 13, // Zoom level
container: "viewDiv" // Div element
});
const featureLayerUrl = "https://services.slip.wa.gov.au/arcgis/rest/services/Landgate_v2_Subscription_Services/Cadastral/MapServer/41";
//const featureLayerUrl = "https://token.slip.wa.gov.au/arcgis/rest/services/Landgate_v2_Subscription_Services/Cadastral/MapServer/41";
var layer = new FeatureLayer({
url: featureLayerUrl,
customParameters: {
"token": token1
}
});
map.add(layer);
});
</script>
This is the Cors challenge:-
Thanks for your time.