Hello,
I'm trying to use the JS client from a HTML page. Here's my code :
<!DOCTYPE html>
<html>
<head>
<title>swagger.js example</title>
<script src='./lib/shred.bundle.js' type='text/javascript'></script>
<script type="text/javascript" src="./lib/swagger.js"></script>
<script type="text/javascript">
window.swagger = new SwaggerApi({
success: function() {
if(swagger.ready === true) {
swagger.apis.location.getLocation({siteKey:"redmarket", externalId:"12"}, function(data) {
document.getElementById("data").innerHTML = data.content.data;
});
}
}
});
</script>
</head>
<body>
<div id="data">
</div>
</body>
</html>
How can I add a basicAuth authentication ? I've tried several things and nothing seems to work.
I've tried to add some http headers in the parameter I give my api method :
swagger.apis.location.getLocation({headers:{"Authorization", "Basic XXX"}, siteKey:"redmarket", externalId:"12"}, function(data) {
document.getElementById("mydata").innerHTML = data.content.data;
});
I've tried to add authorization to the window
window.authorizations.add("basicAuth", new PasswordAuthorization("basicAuth", "test", "XXX"));
And some other (increasingly stupid) solutions. Nothing works.
Any thoughts ?
Thanks !