CredentialsError: Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
See original GitHub issueConfirm by changing [ ] to [x] below to ensure that it’s a bug:
- [x ] I’ve gone through Developer Guide and API reference
- [x ] I’ve checked AWS Forums and StackOverflow for answers
- [ x] I’ve searched for previous similar issues and didn’t find any solution
Describe the bug
I use AWS javascript SDK for enabling my web app clients upload their files to my s3 bucket. But for some client the “managed upload” getting failed (not always but often). Could you please help me debug this, as i am sure i correctly followed all steps mentioned in docs. Please see below for details:
ERROR REPORT
CredentialsError: Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
at r (https://sdk.amazonaws.com/js/aws-sdk-2.818.0.min.js?_=1615666287497:78:2417 )
at constructor.getCredentials (https://sdk.amazonaws.com/js/aws-sdk-2.818.0.min.js?_=1615666287497:78:2945 )
at constructor.<anonymous> (https://sdk.amazonaws.com/js/aws-sdk-2.818.0.min.js?_=1615666287497:79:3316 )
at constructor.callListeners (https://sdk.amazonaws.com/js/aws-sdk-2.818.0.min.js?_=1615666287497:81:6740 )
at constructor.emit (https://sdk.amazonaws.com/js/aws-sdk-2.818.0.min.js?_=1615666287497:81:6480 )
at constructor.emitEvent (https://sdk.amazonaws.com/js/aws-sdk-2.818.0.min.js?_=1615666287497:80:24217 )
at constructor.e (https://sdk.amazonaws.com/js/aws-sdk-2.818.0.min.js?_=1615666287497:80:19827 )
at i.runTo (https://sdk.amazonaws.com/js/aws-sdk-2.818.0.min.js?_=1615666287497:82:30056 )
at constructor.runTo (https://sdk.amazonaws.com/js/aws-sdk-2.818.0.min.js?_=1615666287497:80:21515 )
at constructor.send (https://sdk.amazonaws.com/js/aws-sdk-2.818.0.min.js?_=1615666287497:80:21408 )
SDK script used : https://sdk.amazonaws.com/js/aws-sdk-2.864.0.min.js
AWS initialization Code :
function initializeS3() {
var albumBucketName = aws_details.bucket_name;
var bucketRegion = aws_details.bucket_region;
var IdentityPoolId = aws_details.identity_pool_id;
var IdentityPoolRegion = aws_details.identity_pool_region;
$("#upload-box").draggable();
if(typeof(AWS) != 'undefined') {
console.log("initializing s3 : done");
AWS.config.region = bucketRegion;
AWS.config.update({
region: IdentityPoolRegion,
credentials: new AWS.CognitoIdentityCredentials({
IdentityPoolId: IdentityPoolId
})
});
globalBucket = new AWS.S3({
apiVersion: '2006-03-01',
params: {Bucket: albumBucketName},
httpOptions: {timeout: 1800000}
});
}
else {
console.log("initializing s3 : redo");
setTimeout(initializeS3, 1000);
}
}
UPLAOD CODE:
function process_uq(startingIndex, endingIndex) {
for(current_index = startingIndex; current_index <= endingIndex; current_index++) {
var current_item = global_upload_queue[current_index];
var total_file_size = current_item.size;
var params = {
Bucket: aws_details.bucket_name,
Key: current_item.aws_key,
Body: current_item.file,
ACL: "public-read"
};
global_ongoing_xhr_count++;
global_upload_queue[current_index]['upload_instance'] = new AWS.S3.ManagedUpload({queueSize : 3, partSize : const_min_chunk_size, params : params});
global_upload_queue[current_index]['upload_instance'].on('httpUploadProgress', function(evt) {
var local_uploadPartParams = this.service.config.params;
//for getting queue index from upload id
for(xyz in global_upload_queue) {
if(global_upload_queue[xyz]['aws_key'] == local_uploadPartParams['Key']) {
var local_index = xyz;
}
}
//global_upload_queue[local_index]['total_size_uploaded'] += evt.loaded;
showProgressBarMulti({
uq_index : local_index,
loaded : evt.loaded
});
});
var promise = global_upload_queue[current_index]['upload_instance'].promise();
promise.then(
function(data) {
global_ongoing_xhr_count--;
//for getting queue index from upload id
for(xyz in global_upload_queue) {
if(global_upload_queue[xyz]['aws_key'] == data.Key) {
local_index = xyz;
}
}
var index = local_index;
completeMultiPartUpload(index);
},
function(err) {
console.log("retrying : process_uq(" + startingIndex + ", " + endingIndex + ")");
if(!global_upload_cancelled) {
setTimeout(function() {
process_uq(startingIndex, endingIndex);
sendErrorLogToServer(err.stack);
}, 10000);
}
}
);
}
}
Is the issue in the browser/Node.js? Browser
SDK version number https://sdk.amazonaws.com/js/aws-sdk-2.864.0.min.js
To Reproduce (observed behavior) It is sometime working and sometime failing
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:14 (1 by maintainers)
Top Results From Across the Web
Missing credentials in config, if using AWS_CONFIG_FILE, ...
When using credentials in plain text everything works good but when I am trying to use environment variables it's not working. Error message....
Read more >AWS DynamoDB CredentialsError: Missing credentials in ...
If you're seeing following error when using AWS SDK or CLI: Missing credentials in the config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1 or this:...
Read more >Loading Credentials in Node.js using a Configured ...
To do this, specify a credential process in the shared AWS config file or the shared credentials file. If the AWS_SDK_LOAD_CONFIG environment variable...
Read more >I'm getting a missing credentials error that i can not figure ...
The error code is: 'Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1', require("dotenv").config(); const ...
Read more >[Dimelo Project] AWS S3 - Missing credentials in config, if ...
aws s3 multer로 이미지를 업로드 하려고 하니 다음과 같은 오류가 났다.Missing credentials in config, if using AWS_CONFIG_FILE, set ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Same problem
Hi there, have you tried explicitly setting the credentials in the constructor, I suspect that they get overwritten when the S3 client is initialized.
Basically doing something like:
May also wanna check if they are getting set with using something like:
Also can you point out what documentation you followed?