Fetches a user's app_metadata from Auth0. Args: user_id: Auth0 user ID Returns: app_metadata dict or empty dict if not found
(user_id: str)
| 299 | |
| 300 | |
| 301 | async def get_user_app_metadata(user_id: str) -> dict: |
| 302 | """ |
| 303 | Fetches a user's app_metadata from Auth0. |
| 304 | |
| 305 | Args: |
| 306 | user_id: Auth0 user ID |
| 307 | |
| 308 | Returns: |
| 309 | app_metadata dict or empty dict if not found |
| 310 | """ |
| 311 | try: |
| 312 | token = _get_management_api_token() |
| 313 | headers = {"Authorization": f"Bearer {token}"} |
| 314 | url = f"{MGMT_API_AUDIENCE}users/{user_id}" |
| 315 | |
| 316 | response = requests.get(url, headers=headers) |
| 317 | response.raise_for_status() |
| 318 | |
| 319 | user_data = response.json() |
| 320 | return user_data.get("app_metadata", {}) |
| 321 | except Exception as e: |
| 322 | logger.error(f"Error fetching app_metadata for user {user_id}: {e}") |
| 323 | return {} |
| 324 | |
| 325 | |
| 326 | async def check_apple_subscription_by_email(email: str) -> tuple[bool, str | None]: |
nothing calls this directly
no test coverage detected