Closed flycast closed 6 years ago
Don't use except without a specific exception.
except ForceChangePasswordException:
When this exception occurs you need to call set_new_password_challenge(new_password)
https://github.com/capless/warrant/blob/master/warrant/aws_srp.py#L224
Thanks for the fast response. Changed to:
try:
cog.authenticate(password)
except ForceChangePasswordException:
cog.change_password(password, new_password)
Get:
NameError: name 'ForceChangePasswordException' is not defined
You need to import it from https://github.com/capless/warrant/blob/master/warrant/exceptions.py
Thank you for your patience and help. I really appreciate how prompt you have been.
I am a python 3 noobie. For those who run into this issue you can import the exceptions using:
from warrant.exceptions import *
@flycast it's a bad practice to use '*' in imports, be patient with it.
Better to only import the bare minimum that you need?
from warrant.exceptions import ForceChangePasswordException
Can we close this one?
I'm loathe to re-raise this issue, but I keep getting the following error and it seems connected to this issue:
raise ParamValidationError(report=report.generate_report())
botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid type for parameter AuthParameters.USERNAME, value: None, type: <type 'NoneType'>, valid types: <type 'basestring'>
My code looks like this:
cog = Cognito(identity_pool_id, app_client_id, username)
cog.new_password_challenge(password, new_password)
Where obviously those variables are set elsewhere in my code
OK, this is a really stupid and basic question... 1) Create a new user in a user pool. 2) User tried to authenticate using temporary password. 3) Exception is raised about force password change 4) Try to change password - Can't without access token
Can't get an access token without authenticating. Can't get access token without changing password.
How do we get around this?
I see a number of posts here 25, 13, 14 and 29 but is is still not making sense to my noobie brain.
Traceback (most recent call last): File "C:\Users\Eric\Documents\cognito.py", line 15, in <module> cog.change_password(password, new_password) File "C:\Users\Eric\AppData\Local\Programs\Python\Python36\lib\site-packages\warrant\__init__.py", line 613, in change_password self.check_token() File "C:\Users\Eric\AppData\Local\Programs\Python\Python36\lib\site-packages\warrant\__init__.py", line 253, in check_token raise AttributeError('Access Token Required to Check Token') AttributeError: Access Token Required to Check Token