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

Unable to get user data #232

Open
CGarces-Apser opened this issue Apr 11, 2024 · 1 comment
Open

Unable to get user data #232

CGarces-Apser opened this issue Apr 11, 2024 · 1 comment

Comments

@CGarces-Apser
Copy link

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

    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?

@wazy
Copy link

wazy commented Aug 2, 2024

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

def admin_get_user(self, attr_map=None):

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

2 participants