Closed howardya closed 7 years ago
After referring to this I have modified it to be the following
let Logins = {};
Logins[`cognito-idp.${appConfig.region}.amazonaws.com/${appConfig.UserPoolId}`] = 'xxx';
const myCredentials = new CognitoIdentityCredentials({
IdentityPoolId: appConfig.IdentityPoolId,
region: appConfig.region,
Logins: Logins
});
const dynamodb = new DynamoDB({
IdentityPoolId: appConfig.IdentityPoolId,
region: appConfig.region,
credentials: myCredentials
});
I still have Error: Missing credentials in config
Note: I only import DynamoDB and not the whole AWS using webpack so as to slim down my js file.
Any advice and help? Thank you 👍
@howardya Sorry for the late response.
The error object will include an originalError
field that could give more details. Did your error happen to contain an originalError
that eventually ended with Missing region in config
?
First, to workaround the error you're seeing, you can do something like this before instantiating your CognitoIdentityCredentials
:
var AWS = require('aws-sdk/global');
AWS.config.update({
region: <REGION>
});
Behind the scenes, CognitoIdentityCredentials
calls the CognitoIdentity
service. That service client needs to know what region to hit. By setting the AWS.config.region
to the region your IdentityUserPoolId
is in, CognitoIdentityCredentials
should work.
This is not the best workflow, so what we should do is also allow a way to pass a user-provided region
to the CognitoIdentityCredentials
provider as well.
Hello, I just started on DynamoDB and I do the following
I got Error: Missing credentials in config
How do I pass in my credentials? I have already successfully log into Amazon Cognito and has cognitoUser object.