Reputation: 1362
I am using aws cognito for authenticating and on backend side I need something like admin account to connect with cognito and check user attributes. I found that code below should works, but I got user is not authorized to perform not authorized to perform on ...
How can I create user with such privileges ?
`
let cisp = new AWS.CognitoIdentityServiceProvider()
var params = {
AuthFlow: 'ADMIN_NO_SRP_AUTH',
ClientId: appConfig.ClientId,
UserPoolId: appConfig.UserPoolId,
AuthParameters: {
USERNAME: xxxxxxxxxxxxxxxxx,
PASSWORD: yyyyyyyyyyyyyyyyy
}
}
cisp.adminInitiateAuth(params, (err, data) => {
...
}
`
Upvotes: 0
Views: 1753
Reputation: 19728
You can use the AWS cognito SDK and call the following method to get information about the identity.
describeIdentity(params = {}, callback) ⇒ AWS.Request
If your code runs in AWS EC2, ECS or Lambda, you can attach a IAM role that has access to Cognito so that you code can access the Cognito API through SDK.
Else you need to create a IAM user with Cognito permissions and use AccessKey and Secret to authenticate the SDK API calls impersonating the user.
Upvotes: 1