Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function makeRequest(userTokens) {
console.log("Making API request");
var apigClient = apigClientFactory.newClient({
apiKey: argv.apiKey,
accessKey: AWS.config.credentials.accessKeyId,
secretKey: AWS.config.credentials.secretAccessKey,
sessionToken: AWS.config.credentials.sessionToken,
region: argv.apiGatewayRegion,
invokeUrl: argv.invokeUrl
});
var params = JSON.parse(argv.params);
var additionalParams = JSON.parse(argv.additionalParams);
var body = JSON.parse(argv.body);
if (argv.accessTokenHeader) {
const tokenHeader = {};
tokenHeader[argv.accessTokenHeader] = userTokens.accessToken;
additionalParams.headers = Object.assign({}, additionalParams.headers, tokenHeader);
aws.config.getCredentials(function(err) {
if (err) {
credFailureCount++;
console.log("Error retrieving credentials:" + err);
if (credFailureCount < 5) {
console.log("Retrying");
return getCredentials();
} else {
return Project.reject('Failure retrieving credentials.')
}
}
credentialsReady = 1;
apiClient = apiClientFactory.newClient({
invokeUrl: "https://" + apigateway + "/v1/statusreport/",
accessKey: aws.config.credentials.accessKeyId,
secretKey: aws.config.credentials.secretAccessKey,
sessionToken: aws.config.credentials.sessionToken,
region: "us-west-2"
});
setTimeout(getCredentials, 600);
return success(true);
});
});