Removing AuthenticatedClient in favor of Client.with_authorization_header and Generics #1287
alexandervaneck
started this conversation in
Feature request
Replies: 2 comments
-
Oh, and this would be a breaking change as |
Beta Was this translation helpful? Give feedback.
0 replies
-
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I've been exploring this package and am very excited about the output it generates. Especially the extensibility due to the jinja2 templating is great! Thank you for maintaining it. 🙇
After generating a client I noticed that there's a lot of duplication between AuthenticatedClient and Client. From what I can tell the usage of AuthenticatedClient is:
Setting authentication headers
Currently we solve for this usecase:
However, when the token needs to change (f.e. b/c different users use different tokens) then we'd have to completely change the client. Leading to the
httpx.ClientSession
being recreated and causing overhead.It might be nicer to instead have methods on
Client
to set and del authorization headers so that the Client can be longlived and the authentication can vary per request.The added benefit here is that we can solve for #823 by adding
with_authorization_basic
as well. Without duplicating Client more.Type hinting
To make clear when an endpoint requires authentication headers set we can add a phantom type parameter.
Let me know what you think. I'm happy to suggest the PR 🙇 and thanks again!
Beta Was this translation helpful? Give feedback.
All reactions