Skip to content

[Improvement] Add authorization support to ClientSession #17

Description

@mchades

What would you like to be improved?

ClientSession and stdio_client have no built-in way to attach authorization credentials to outgoing requests. Callers who connect to a secured ADP server must manually manipulate request params to pass credentials, which is error-prone and not ergonomic.

Two specific gaps:

  1. No authorization parameter on ClientSession.__init__ or stdio_client
  2. No helper to construct a standard Basic authorization header value

How should we improve?

  1. Add authorization: str | None = None to ClientSession.__init__ and stdio_client
  2. When set, automatically inject authorization into _meta of every outgoing JSON-RPC request
  3. Add a basic_auth(username, password) helper that returns a properly Base64-encoded Basic <token> header value
  4. Export basic_auth from adp_sdk.client and the top-level adp_sdk package

Usage example:

from adp_sdk import stdio_client, basic_auth

async with stdio_client(
    "python", ["-m", "adp_hypervisor"],
    authorization=basic_auth("alice", "secret"),
) as session:
    resources = await session.discover()

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions