I'm attempting to better understand the AGS token service and cannot seem to get thru some errors (probably something simple I'm missing). For starters, I simply just want to generate a token for a secured feature service and see it as a string/console. That's it.
Here's my sample that is hitting the error "Method not supported" in the console.log(error.message)….
var tokRequest = esriRequest({
url: "https://myAGS/tokens/generateToken",
method: "post",
content: {
f: "json",
username: "myUsername",
password: "myPassword",
referer: "<https://myAppPageURL>"
}
}).then(
function (response) {
console.log("Success: ", response.toJson);
}, function (error) {
console.log("Error: ", error.message);
});
Any help is appreciated.