Skip to content

Update PriceCharting clients and authentication security - #12

Merged
ahcodedev merged 1 commit into
mainfrom
pricecharting-auth-handling
Nov 9, 2026
Merged

ahcodedev merged 1 commit into
mainfrom
pricecharting-auth-handling

Conversation

@ahcodedev

@ahcodedev ahcodedev commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Summary

Update both clients to handle the API token with increased redaction.

Token handling (PriceCharting and AsyncPriceCharting)

  • The constructor argument is now token: str | None = None. If it is omitted, the token is read from the PRICECHARTING_TOKEN environment variable (TOKEN_KEY).
  • The constructor raises ValueError when no token is found or the token is not 40 characters, so a bad token fails immediately instead of on the first request.
  • The token is stored as a pydantic SecretStr in a private _token so it shows as ********** in debuggers and error reports.

Request authentication (_auth.py)

  • _TokenAuth is an httpx2.Auth shared by both clients. It adds the token as t to the query string for GET requests and to the form body for POST requests, as the API requires. It replaces any existing t and recalculates Content-Length and Content-Type for POST bodies.

Log redaction

  • httpx2 logs every request URL at INFO level, and that URL includes t=<token> for GET requests. _REDACT_FILTER is a single logging.Filter that each client attaches to the httpx2 logger. It rewrites the token to t=REDACTED before any handler sees the record.

Docs

  • The constructor docstrings now document the env var fallback, the ValueError cases and the logger filter.
  • docs/index.md has new Authentication and Security sections. The Security section notes that the token is still visible in URLs to anything outside the library, such as proxies.

Type of Change

Feature

Checklist

  • just lint passes
  • just test passes
  • Tests added or updated for the change
  • Docs updated if needed (README.md, docs/, CLAUDE.md)
  • Release label added

@ahcodedev ahcodedev added the feature New feature (minor version bump) label Nov 9, 2026
@ahcodedev
ahcodedev merged commit 25aa9da into main Nov 9, 2026
11 checks passed
@ahcodedev
ahcodedev deleted the pricecharting-auth-handling branch November 9, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature (minor version bump)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant