Skip to content

Generate API key auth for Python clients - #960

Merged
stobrien89 merged 1 commit into
developfrom
python-client-generic-auth
Nov 20, 2026
Merged

stobrien89 merged 1 commit into
developfrom
python-client-generic-auth

Conversation

@stobrien89

Copy link
Copy Markdown
Contributor

Issue #, if available:

Description of changes:

Python clients now support httpApiKeyAuth, which is the only auth scheme the Java generator supports. Before this, the generator rejected any operation that needed auth.

  • _auth.py adds an auth registry keyed by trait ID, like the protocol registry. API key auth is the only entry.
  • Configs match Java:
    • api_key and api_key_identity_resolver fields
    • auth_schemes defaults to APIKeyAuthScheme, or AsyncAPIKeyAuthScheme in the async config
    • set_auth_scheme
  • Unlike Java, the resolver stays DefaultAuthResolver. Java's generated HTTPAuthSchemeResolver checks auth_parameters.operation == "Health", but operation is an APIOperation, so the check is never true and @auth([]) operations get signed. I checked this against Java's output for the new fixture. DefaultAuthResolver uses each operation's effective schemes, so those operations go out unsigned.
  • Generation still fails when an operation has no supported scheme and no noAuth, so a bearer-only operation isn't silently sent unsigned.
  • There's a new api-key-auth-client snapshot, built from models/api-key-auth.smithy. Its tests cover a signed operation, @auth([]), @optionalAuth, and a missing key.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@stobrien89
stobrien89 merged commit c2d5909 into develop Nov 20, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants