capless / warrant

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

change_password: Access Token Required to Check Token #29

Closed mscheper closed 7 years ago

mscheper commented 7 years ago

I apologise if this isn't the right place to post what's probably a naïve question. Let me know if there's a better place.

I don't seem to be able to get change_password to work. Or is this in essence what #13 is about?

    cognito = Cognito(identity_pool_id, app_client_id, username=username)

    cognito_id_token = cognito.id_token
    cognito_refresh_token = cognito.refresh_token
    cognito_access_token = cognito.access_token

    try:
        cognito.authenticate(password=password)
    except ForceChangePasswordException:
        cognito2 = Cognito(identity_pool_id, app_client_id,
                id_token = cognito_id_token,
                refresh_token = cognito_refresh_token,
                access_token = cognito_access_token,
        )
        cognito2.change_password(password, new_password)

This is the exception I get:

  File (my dodgy code), in my_function
    cognito2.change_password(password, new_password)
  File ".../warrant/__init__.py", line 515, in change_password
    self.check_token()
  File ".../warrant/__init__.py", line 196, in check_token
    raise AttributeError('Access Token Required to Check Token')
AttributeError: Access Token Required to Check Token
mscheper commented 7 years ago

Never mind. This is pretty much a dupe of #14.

mscheper commented 7 years ago

I just found that the fix described in #25 already works, too. new_password_challenge() isn't documented in README.md, though. I'm happy to add it, if it doesn't steal anyone's thunder. @bjinwright?

bjinwright commented 7 years ago

I always welcome PRs especially README PRs