Authentication and jQuery
Not mentioned in OP, but a setting of
data : {"access_token" : “<token>”}
does work and allows me access to the endpoint, but this does not seem to be a satisfying solution which is why I posted the question and I am interested if there is a better way.
You can simply access APIs with jQuery code like this:
var url = "https://api.guildwars2.com/v2/account?access_token=" + my_api_key;
$.getJSON(url, function(data) {
// use your data
}).fail(function(xhr) {
console.log("Error: " + $.parseJSON(xhr.responseText).text);
});
EDIT:
The endpoint uses GET method to authenticate your token. So you can add it in the URL like above or set it in the data settings in jQuery’s $.ajax or $.getJSON methods.
(edited by Nier.6408)