Files
saladeaula.digital/http-api/cognito.py
2025-03-27 01:14:18 -03:00

12 lines
395 B
Python

class UserNotFound(Exception): ...
def get_user(access_token: str, *, idp_client) -> dict | None:
"""Gets the user attributes and metadata for a user."""
try:
user = idp_client.get_user(AccessToken=access_token)
except idp_client.exceptions.ClientError:
raise UserNotFound()
else:
return {attr['Name']: attr['Value'] for attr in user['UserAttributes']}