diff --git a/pycognito/__init__.py b/pycognito/__init__.py index bd28318a..f0c56596 100644 --- a/pycognito/__init__.py +++ b/pycognito/__init__.py @@ -310,6 +310,13 @@ def get_user_obj( what we'd like to display to the users :return: dictionary of the Cognito user response """ + # try to detect the username from self or from the metadata if not set + if username is None: + if metadata is None: + username = self.username + else: + username = self.username or metadata.get("username") + return self.user_class( username=username, attribute_list=attribute_list,