Skip to main content

Autodesk Platform Services: shared HTTP client and authentication utilities for Kiota-based SDKs

Project description

adsk-platform-httpclient

Shared HTTP client, authentication, and middleware utilities for Autodesk Platform Services Python SDKs.

This package provides the foundational components used by all adsk-platform-* SDK packages.

Installation

pip install adsk-platform-httpclient

Note: You typically don't need to install this package directly. It's automatically included as a dependency of the SDK packages (e.g., adsk-platform-acc, adsk-platform-data-management).

Components

HttpClientFactory

Creates pre-configured httpx.AsyncClient instances and Kiota request adapters with bearer-token authentication and the custom middleware pipeline.

from autodesk_common_httpclient import HttpClientFactory

async def get_access_token() -> str:
    return "YOUR_ACCESS_TOKEN"

# Create a Kiota request adapter with authentication + middleware
adapter = HttpClientFactory.create_adapter(get_access_token)

# Or provide your own httpx client
import httpx
custom_client = httpx.AsyncClient(timeout=60.0)
adapter = HttpClientFactory.create_adapter(get_access_token, http_client=custom_client)

AccessTokenProviderCallback

Wraps an async callback into a Kiota-compatible AccessTokenProvider.

from autodesk_common_httpclient import AccessTokenProviderCallback

provider = AccessTokenProviderCallback(get_access_token)

Custom Middleware

The package includes three custom middleware handlers that are automatically added to the HTTP pipeline, matching the C# Autodesk.Common.HttpClientLibrary.Middleware:

ErrorHandler

Raises an httpx.HTTPStatusError when the HTTP response has a non-success status code (4xx/5xx). Enabled by default.

from autodesk_common_httpclient import ErrorHandlerOption

# Disable for a specific request
error_option = ErrorHandlerOption(enabled=False)

QueryParameterHandler

Appends or overwrites query parameters on every outgoing request. Useful for injecting API versions, region codes, or tracking identifiers.

from autodesk_common_httpclient import QueryParameterHandlerOption

query_option = QueryParameterHandlerOption(query_parameters={"region": "US"})

RateLimitingHandler

Limits the number of concurrent requests per endpoint within a sliding time window. Disabled by default.

from autodesk_common_httpclient import RateLimitingHandlerOption

# Allow max 10 requests per endpoint per 60 seconds
rate_option = RateLimitingHandlerOption()
rate_option.set_rate_limit(max_requests=10, time_window_seconds=60.0)

Creating a client with rate limiting

from autodesk_common_httpclient import HttpClientFactory

# Create an HTTP client with rate limiting enabled
client = HttpClientFactory.create_with_rate_limit(
    max_requests=10,
    time_window_seconds=60.0,
)

# Use it with any SDK client
adapter = HttpClientFactory.create_adapter(get_access_token, http_client=client)

Middleware Pipeline Order

The middleware is executed in this order (matching the C# implementation):

  1. Kiota defaults — Redirect, Retry, Parameters Name Decoding, URL Replace, User Agent, Headers Inspection
  2. RateLimitingHandler — Per-endpoint rate limiting
  3. QueryParameterHandler — Query parameter injection
  4. ErrorHandler — Error response detection

Requirements

  • Python 3.10 or later

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

adsk_platform_httpclient-0.2.9.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

adsk_platform_httpclient-0.2.9-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file adsk_platform_httpclient-0.2.9.tar.gz.

File metadata

  • Download URL: adsk_platform_httpclient-0.2.9.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for adsk_platform_httpclient-0.2.9.tar.gz
Algorithm Hash digest
SHA256 a35d28a4b5359a47e1fb5ed872bb31bf1127e499472f6a5fc04fa8f692089a96
MD5 6619bb5fece83106d0e7657e335bc9f8
BLAKE2b-256 61af6f1e55c7ce6cb309284bdc3eb0f2d11a9b89792efd1592481192094d88ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for adsk_platform_httpclient-0.2.9.tar.gz:

Publisher: publishPyPi.yml on adsk-duszykf/Adsk.Platform.Toolkit.Python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file adsk_platform_httpclient-0.2.9-py3-none-any.whl.

File metadata

File hashes

Hashes for adsk_platform_httpclient-0.2.9-py3-none-any.whl
Algorithm Hash digest
SHA256 ec8123cfbfc9de473ff356b1be2df6473f3df55076f79daf98f8d4d2866bd9dc
MD5 1e0af29abcb6414afb70a2bc24f75840
BLAKE2b-256 419874aef0ef0d79194ee30a67e3296ea4e23adc99c630d40d7bc63a0d8e26db

See more details on using hashes here.

Provenance

The following attestation bundles were made for adsk_platform_httpclient-0.2.9-py3-none-any.whl:

Publisher: publishPyPi.yml on adsk-duszykf/Adsk.Platform.Toolkit.Python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page