Skip to content

AmazonCreatorsApi has no proxy support — regular calls and OAuth2 token refresh both bypass HTTP proxy #149

@mekarpeles

Description

@mekarpeles

Note

I liberally used AI Models to help with the organization of this issue; it's a real use case motivated by Open Library (which requires http_proxy in order to make network requests)

Summary

Two independent gaps prevent AmazonCreatorsApi from routing traffic through an HTTP proxy.

Problem 1 — no proxy parameter on AmazonCreatorsApi

AmazonCreatorsApi.__init__ creates ApiClient without a Configuration, so
configuration.proxy is always None. RESTClientObject already handles urllib3.ProxyManager
when configuration.proxy is set — the plumbing is there, it just isn't reachable from the
public API.

Problem 2 — OAuth2TokenManager.refresh_token() bypasses proxy entirely

Even if configuration.proxy were set, token refresh would still go direct:

# oauth2_token_manager.py
response = requests.post(self.config.get_cognito_endpoint(), ...)

This bare requests.post() has no proxy configuration. Token refresh on a cold cache
(worker restart, token expiry) cannot be routed through an authenticated proxy.

Real-world context

Open Library (Internet Archive) runs behind an authenticated Squid proxy. Adding Creators API
support required two separate workarounds to paper over both gaps:

Both hacks could be removed if proxy support were native to the library.

Proposed fix

Add proxy: str | None = None to AmazonCreatorsApi.__init__ (e.g. "http://user:pass@proxy:3128"),
pass it to ApiClient via a Configuration object, and have OAuth2TokenManager use a
requests.Session with .proxies set when a proxy URL is provided.

The Configuration class and RESTClientObject already have the right structure — this is
purely a wiring change.

Will proactively submit a PR for your consideration

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions