Open CGarces-Apser opened 7 months ago
I'm trying to fetch data from a user using pycognito.
This code give all de users in the pool, so the connection to AWS is working fine
c = Cognito( cognito_service.COGNITO_USER_POOL_ID, cognito_service.COGNITO_APP_CLIENT_ID ) response = c.get_users(attr_map={})
But the same code using get_user_obj
c = Cognito( cognito_service.COGNITO_USER_POOL_ID, cognito_service.COGNITO_APP_CLIENT_ID ) response = c.get_user_obj(username=username, attribute_list=[{}])
Always return a dummy object with all values set to None except for the username that is populated allways, also with not existing users.
I have tested also get_user
get_user
c = Cognito( cognito_service.COGNITO_USER_POOL_ID, cognito_service.COGNITO_APP_CLIENT_ID, username=username, ) response = c.get_user(attr_map={})
That raise a boto3 exception
botocore.exceptions.ParamValidationError: Parameter validation failed: Invalid type for parameter AccessToken, value: None, type: <class 'NoneType'>, valid types: <class 'str'>
My cognito pool use only "email", not "username" for login, I'm not sure if is de reason for the error.
Any hint to solve my issues fetching the user data?
This is because get_user uses the user's access token to get their information. If you just want to get a user's information without them having logged in and having a token then you should use admin_get_user
https://github.com/NabuCasa/pycognito/blob/559462af7e91a9a5b85aa79278c83b030aa05a47/pycognito/__init__.py#L609
I'm trying to fetch data from a user using pycognito.
This code give all de users in the pool, so the connection to AWS is working fine
But the same code using get_user_obj
Always return a dummy object with all values set to None except for the username that is populated allways, also with not existing users.
I have tested also
get_user
That raise a boto3 exception
My cognito pool use only "email", not "username" for login, I'm not sure if is de reason for the error.
Any hint to solve my issues fetching the user data?