I am trying to add a user to cognito and assign it a group. Adding to group is successful, but I cannot add to which group a user belongs.
import boto3
email = '[email protected]'
poolId = 'ap-northeast-1_xxxxxx'
group = 'xxxx'
password = 'String1234'
aws_access_key_id = 'Axxxxxxxx'
aws_secret_access_key = '6xxxxxxxxx'
session = boto3.Session(aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key)
client = session.client('cognito-idp')
response = client.admin_create_user(
UserPoolId=poolId,
Username=email,
TemporaryPassword= password,
UserAttributes=[
{
"Name": "email",
"Value": email
},
{
"Name": "email_verified",
"Value": "true"
}
]
)
response = client.admin_add_user_to_group(
UserPoolId=poolId,
Username=email,
GroupName=group
)
The user is added successfully but a group is not added:
Traceback (most recent call last): File "test.py", line 24, in <module>
response = client.admin_add_user_to_group
( AttributeError: 'CognitoIdentityProvider' object has no attribute 'admin_add_user_to_group'
In my requirements.txt for creating virtual enviorment for python I use
boto3==1.4.5
Using this boto3 docs for reference.