Skip to main content
Glama
credential_service.py1.23 kB
"""Hostaway credential validation and expiration detection""" from datetime import datetime from typing import NamedTuple import httpx class DecryptedCredentials(NamedTuple): """Decrypted Hostaway credentials for API requests.""" account_id: str secret_key: str async def check_credential_validity(account_id: str, secret_key: str) -> dict: """Test Hostaway credentials by making API call""" try: async with httpx.AsyncClient(timeout=10.0) as client: response = await client.get( "https://api.hostaway.com/v1/listings", headers={ "Authorization": f"Bearer {secret_key}", "Content-type": "application/json", }, params={"limit": 1}, ) if response.status_code == 401: return {"valid": False, "error": "Invalid or expired credentials"} if response.status_code == 200: return {"valid": True, "validated_at": datetime.now(tz=None).isoformat()} return {"valid": False, "error": f"Unexpected status: {response.status_code}"} except Exception as e: return {"valid": False, "error": str(e)}

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/darrentmorgan/hostaway-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server