capless / warrant

Python library for using AWS Cognito. With support for SRP.
Apache License 2.0
468 stars 192 forks source link

required attributes not supported #51

Closed mscansian closed 6 years ago

mscansian commented 6 years ago

I have a user pool with "name" as a required attribute, but when I try to authenticate an user I get the following response.

Code:

import boto3
from warrant import Cognito
from warrant.aws_srp import AWSSRP
from warrant.exceptions import ForceChangePasswordException

try:
    cognito_idp = boto3.client('cognito-idp')
    aws = AWSSRP(username='user@email.com', password='mypassword',
                 pool_id='pool-id', client_id='client-id', client=cognito_idp)
    tokens = aws.authenticate_user()
except ForceChangePasswordException:
    tokens = aws.set_new_password_challenge(new_password="mypassword2")

Response:

Traceback (most recent call last):
  File "auth.py", line 14, in <module>
    tokens = aws.set_new_password_challenge(new_password="mypassword2")
  File "/usr/local/lib/python3.6/dist-packages/warrant/aws_srp.py", line 231, in set_new_password_challenge
    ChallengeResponses=challenge_response)
  File "/home/matheus/.local/lib/python3.6/site-packages/botocore/client.py", line 312, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/home/matheus/.local/lib/python3.6/site-packages/botocore/client.py", line 601, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.InvalidParameterException: An error occurred (InvalidParameterException) when calling the RespondToAuthChallenge operation: Invalid attributes given, name is missing

I'm new to AWS Cognito, but I think that I also need to provide the required attributes with this auth challenge. Any ideas?

bjinwright commented 6 years ago

Follow the steps below:

  1. Click the App Clients link when viewing your user group on the
  2. Click the app client that you are using and then click the Show Details button
  3. Click the Set attribute read and write permissions link.
  4. Check the attributes that you need.
aleGpereira commented 5 years ago

Sorry, i can't understand where i should put this required attributes in the code to succeed set_new_password_challenge. Can you explain?