Skip to content

auth

framewise_meet_client.auth

authenticate_api_key(api_key)

Authenticate an API key.

This implementation validates the API key against a remote server.

Parameters:

Name Type Description Default
api_key str

The API key to authenticate

required

Returns:

Type Description
bool

True if authentication succeeded, False otherwise

Source code in framewise_meet_client/auth.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
def authenticate_api_key(api_key: str) -> bool:
    """Authenticate an API key.

    This implementation validates the API key against a remote server.

    Args:
        api_key: The API key to authenticate

    Returns:
        True if authentication succeeded, False otherwise
    """
    if not api_key:
        logger.warning("Empty API key provided")
        return False

    logger.debug("Authenticating API key...")

    url = 'https://backend.framewise.ai/api/py/validate-api-key'
    headers = {
        'accept': 'application/json',
        'Content-Type': 'application/json'
    }
    data = {
        'api_key': api_key
    }

    try:
        response = requests.post(url, headers=headers, json=data)
        response.raise_for_status()
        result = response.json()
        return result.get('is_valid', False)
    except requests.RequestException as e:
        logger.error(f"Error during API key authentication: {e}")
        return False