`CredentialsError` : “Missing credentials in config” while adding user to group in AWS cognito

The name of the picture


`CredentialsError` : “Missing credentials in config” while adding user to group in AWS cognito



I get this error while I am trying to add an user to Cognito User group using adminAddUserToGroup method


adminAddUserToGroup


const AWSConfig = require("./cognito.js")
const AWS = require("aws-sdk");
const AWSCognito = require('./amazon-cognito-identity.min.js');


AWS.config.region = 'ap-south-1'; // Region
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: AWSConfig.UserPoolId
});

let cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider({
apiVersion: '2016-04-18',
region:'ap-south-1',
credentials: {
IdentityPoolId: AWSConfig.identity_pool_id
}
});

var params = {
GroupName: req.body.group_name,
/* required */
UserPoolId: AWSConfig.UserPoolId,
/* required */
Username: req.body.preferred_username /* required */
};

cognitoidentityserviceprovider.adminAddUserToGroup(params, function (err, data) {
if (err) res.send(err); // an error occurred
else res.send(data);; // successful response
});



I tried looking of web and AWS documentation but i get conflicting answers and not a single solution.



P.S: I am using amazon-cognito-identity.min.js


amazon-cognito-identity.min.js


{
"message": "Missing credentials in config",
"code": "CredentialsError",
"time": "2018-07-26T12:10:47.493Z",
"originalError": {
"message": "Missing credentials",
"code": "CredentialsError",
"time": "2018-07-26T12:10:47.493Z"
}
}



this is the error I get.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Better method to check all objects' parameters with a single call

C++ virtual function: Base class function is called instead of derived