Skip to content

ccproxy.auth.bearer

ccproxy.auth.bearer

Bearer token authentication implementation.

BearerTokenAuthManager

BearerTokenAuthManager(token)

Bases: BaseAuthManager

Authentication manager for static bearer tokens.

Parameters:

Name Type Description Default
token str

Bearer token string

required
Source code in ccproxy/auth/bearer.py
def __init__(self, token: str) -> None:
    """Initialize with a static bearer token.

    Args:
        token: Bearer token string
    """
    self.token = token.strip()
    if not self.token:
        raise ValueError("Token cannot be empty")

get_access_token async

get_access_token()

Get the bearer token.

Returns:

Type Description
str

Bearer token string

Raises:

Type Description
AuthenticationError

If token is invalid

Source code in ccproxy/auth/bearer.py
async def get_access_token(self) -> str:
    """Get the bearer token.

    Returns:
        Bearer token string

    Raises:
        AuthenticationError: If token is invalid
    """
    if not self.token:
        raise AuthenticationError("No bearer token available")
    return self.token

get_credentials async

get_credentials()

Get credentials (not supported for bearer tokens).

Raises:

Type Description
AuthenticationError

Bearer tokens don't support full credentials

Source code in ccproxy/auth/bearer.py
async def get_credentials(self) -> ClaudeCredentials:
    """Get credentials (not supported for bearer tokens).

    Raises:
        AuthenticationError: Bearer tokens don't support full credentials
    """
    raise AuthenticationError(
        "Bearer token authentication doesn't support full credentials"
    )

is_authenticated async

is_authenticated()

Check if bearer token is available.

Returns:

Type Description
bool

True if token is available, False otherwise

Source code in ccproxy/auth/bearer.py
async def is_authenticated(self) -> bool:
    """Check if bearer token is available.

    Returns:
        True if token is available, False otherwise
    """
    return bool(self.token)

get_user_profile async

get_user_profile()

Get user profile (not supported for bearer tokens).

Returns:

Type Description
UserProfile | None

None - bearer tokens don't support user profiles

Source code in ccproxy/auth/bearer.py
async def get_user_profile(self) -> UserProfile | None:
    """Get user profile (not supported for bearer tokens).

    Returns:
        None - bearer tokens don't support user profiles
    """
    return None