Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

register function error, TypeError #115

Open
koorukuroo opened this issue Jun 5, 2018 · 4 comments
Open

register function error, TypeError #115

koorukuroo opened this issue Jun 5, 2018 · 4 comments

Comments

@koorukuroo
Copy link

koorukuroo commented Jun 5, 2018

There are TypeError for register like #69

I try to it in branch of master, develop, features... But these have same error.

u.add_base_attributes(email='[email protected]')
u.add_custom_attributes(state='virginia', city='Centreville')
u.register(username='xxx', password='qwerty234@$')

Error Message

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-7-1104a483b338> in <module>()
     14 u.add_base_attributes(email='[email protected]')
     15 u.add_custom_attributes(state='virginia', city='Centreville')
---> 16 u.register(username='xxx', password='qwerty234@$')

~/anaconda3/envs/A/lib/python3.6/site-packages/warrant/__init__.py in register(self, username, password, attr_map)
    308             'UserAttributes': cognito_attributes
    309         }
--> 310         self._add_secret_hash(params, 'SecretHash')
    311         response = self.client.sign_up(**params)
    312 

~/anaconda3/envs/A/lib/python3.6/site-packages/warrant/__init__.py in _add_secret_hash(self, parameters, key)
    626         if self.client_secret is not None:
    627             secret_hash = AWSSRP.get_secret_hash(self.username, self.client_id,
--> 628                                                  self.client_secret)
    629             parameters[key] = secret_hash
    630 

~/anaconda3/envs/A/lib/python3.6/site-packages/warrant/aws_srp.py in get_secret_hash(username, client_id, client_secret)
    169     @staticmethod
    170     def get_secret_hash(username, client_id, client_secret):
--> 171         message = bytearray(username + client_id, 'utf-8')
    172         hmac_obj = hmac.new(bytearray(client_secret, 'utf-8'), message, hashlib.sha256)
    173         return base64.standard_b64encode(hmac_obj.digest()).decode('utf-8')

TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
@BabyDino
Copy link

BabyDino commented Jun 20, 2018

I am experiencing the same issue.

Found the error @koorukuroo

u = Cognito('eu-west-1_xxxx', 'xxxx', client_secret='xxxxx',username='[email protected]')

u.add_base_attributes(email='[email protected]',locale='nl_NL',given_name='Test',family_name='Test')

u.register('[email protected]','Test1234!')

You have to add the username to Cognito() as well.

@dperconti
Copy link

I'm experiencing the same issue as well. @BabyDino or @koorukuroo - were either of you able to figure out the issue/solution for this?

@BabyDino
Copy link

See my code above, did you add username='[email protected]'?

@dperconti
Copy link

I ended up creating a client without a secret (still without username), which is now working. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants