Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Client.auth setter #1185

Merged
merged 2 commits into from Aug 17, 2020
Merged

Add Client.auth setter #1185

merged 2 commits into from Aug 17, 2020

Conversation

florimondmanca
Copy link
Member

@florimondmanca florimondmanca commented Aug 16, 2020

Closes #1066

Make Client.auth / AsyncClient.auth properties, so that .auth can be set using the same argument types and logic than passed on client init.

client = httpx.Client()
client.auth = ("username", "p@ssw0rd")
response = client.get(...)  # Uses Basic Auth.

Implementation-wise, we split the existing ._build_auth(request, auth) helper into ._build_auth(auth) and ._build_request_auth(request, auth). The former converts AuthTypes to an Optional[Auth] and is used in the .auth setter as well as in ._build_request_auth() to convert the request-level auth info.

@florimondmanca florimondmanca requested a review from a team August 16, 2020 07:45
@tomchristie tomchristie mentioned this pull request Aug 16, 2020
6 tasks
@florimondmanca florimondmanca merged commit cb620e6 into master Aug 17, 2020
@florimondmanca florimondmanca deleted the fm/client-auth-property branch August 17, 2020 12:51
@tomchristie tomchristie mentioned this pull request Aug 21, 2020
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.

Public API tightening
2 participants