We use aws and swagger, also we have a service with getData method
var getData = () => {
return $http({
method: 'GET',
url: 'myURL',
headers: {
'Authorization': 'token'
}
});
};
I'm trying to use it with bellow code
dataservice.getData().then(response => {
console.log(response)
})
.catch((err) => {
console.log(err));
})
And for good request (when I'm autorized) it works fine, I get my data, but then token is not valid I'm gettin error whitout status code in console
Object {data: null, status: -1, config: Object, statusText: "", headers: function}
swagger returns bellow picture
My goal is to get status code 401 'not autorized'
Our lamba has bellow structure
exports.handler = (event, context, callback) => {
var token = event.authorizationToken;
// Call oauth provider, crack jwt token, etc.
// In this example, the token is treated as the status for simplicity.
switch (token.toLowerCase()) {
case 'allow':
callback(null, generatePolicy('user', 'Allow', event.methodArn));
break;
case 'deny':
callback(null, generatePolicy('user', 'Deny', event.methodArn));
break;
case 'unauthorized':
callback("Unauthorized"); // Return a 401 Unauthorized response
break;
default:
callback("Error: Invalid token");
}
};
we get this from awsdoc