Skip to content

codingame_tools.client.service.services.intercom

intercom

Async Intercom service endpoint.

CgIntercomServiceHelper

CgIntercomServiceHelper(service)

Bases: CgServiceHelper['CgIntercomService']

Helper methods for CgIntercomService. Currently empty.

Source code in codingame_tools/client/service/cg_service.py
124
125
def __init__(self, service: TService) -> None:
    self.service = service

CgIntercomService

CgIntercomService(client)

Bases: CgService

Async Intercom service endpoint.

Source code in codingame_tools/client/service/services/intercom.py
23
24
25
def __init__(self, client: CgClient) -> None:
    super().__init__(client, "Intercom")
    self.helper = CgIntercomServiceHelper(self)

generate_token async

generate_token()

Generate an Intercom identity-verification JWT for the logged-in codingamer, used to authenticate the user's identity to Intercom's live-chat widget.

The decoded JWT payload (HS256, audience "Intercom") contains standard identity claims: user_id, email, pseudo, language_override, plus iat/exp (observed validity: 1 hour).

Returns None if Intercom is not available for the logged-in codingamer--observed for one real, logged-in account, reason unknown (possibly an account/plan-specific feature gate). This is a genuine, successfully-decoded null response, not an error.

Returns:

  • str | None

    The signed JWT string, or None if not available for this codingamer.

Raises:

  • CgAuthenticationError

    If the session is not authenticated and cannot implicitly login.

  • CgClientHttpError

    If a transport error occurs, if the response content could not be decoded at all, if the status code is not 2xx, or if the decoded content is neither a str nor null.

Source code in codingame_tools/client/service/services/intercom.py
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
async def generate_token(self) -> str | None:
    """Generate an Intercom identity-verification JWT for the logged-in codingamer, used to
       authenticate the user's identity to Intercom's live-chat widget.

       The decoded JWT payload (HS256, audience "Intercom") contains standard identity
       claims: `user_id`, `email`, `pseudo`, `language_override`, plus `iat`/`exp` (observed
       validity: 1 hour).

       Returns None if Intercom is not available for the logged-in codingamer--observed for
       one real, logged-in account, reason unknown (possibly an account/plan-specific
       feature gate). This is a genuine, successfully-decoded `null` response, not an error.

    Returns:
        The signed JWT string, or None if not available for this codingamer.

    Raises:
        CgAuthenticationError:
            If the session is not authenticated and cannot implicitly login.
        CgClientHttpError:
            If a transport error occurs, if the response content could not be decoded at all,
            if the status code is not 2xx, or if the decoded content is neither a str nor null.
    """
    result = await self.service_request("generateToken")
    if result is None:
        return None
    if not isinstance(result, str):
        raise CgClientHttpError(
                f"Invalid response type: expected a JSON string or null, got {type(result).__name__}",
                content=result,
            )
    return result