Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create user in amazon-cognito using boto3 in python

I'm trying to create user using python3.x and boto3 but end up with facing some issues

I've tried using "admin_create_user" even id didn't worked for me

import boto3
aws_client = boto3.client('cognito-idp', 
    region_name = CONFIG["cognito"]["region"]
)
response = aws_client.admin_create_user(
    UserPoolId = CONFIG["cognito"]["pool_id"],
    Username = email, 
    UserAttributes = [
        {"Name": "first_name", "Value": first_name},
        {"Name": "last_name", "Value": last_name},
        { "Name": "email_verified", "Value": "true" }
    ],
    DesiredDeliveryMediums = ['EMAIL']
)

Error facing

like image 247
Kowthavarapu Manohar Avatar asked Jun 21 '19 06:06

Kowthavarapu Manohar


1 Answers

  • I think you didn't pass the configuration. First install the AWS CLI.

pip install awscli --upgrade --user

  • Then type below command in your terminal,

aws configure

  • Provide your details correctly,
AWS Access Key ID [****************6GOW]: 
AWS Secret Access Key [****************BHOD]: 
Default region name [us-east-1]: 
Default output format [None]:

Try this and you can also view your credentials in below paths.

sudo cat ~/.aws/credentials

[default]
aws_access_key_id = ******7MVXLBPHW66GOW
aws_secret_access_key = wKtT*****UqN1sO/1Pfn+BCrvNst*****695BHOD
sudo cat ~/.aws/config

[default]
region = us-east-1

or you can view all those in one place by aws configure list command,

enter image description here

like image 184
Kushan Gunasekera Avatar answered Oct 19 '22 14:10

Kushan Gunasekera