Skip to content

Add Client.auth setter - #1185

Merged
florimondmanca merged 2 commits into
masterfrom
fm/client-auth-property
Aug 17, 2020
Merged

Add Client.auth setter#1185
florimondmanca merged 2 commits into
masterfrom
fm/client-auth-property

Conversation

@florimondmanca

@florimondmancaflorimondmanca commented Aug 16, 2020

Copy link
Copy Markdown
Contributor

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 teamAugust 16, 2020 07:45
@florimondmanca
florimondmanca merged commit cb620e6 into masterAug 17, 2020
@florimondmanca
florimondmanca deleted the fm/client-auth-property branch August 17, 2020 12:51
@lovelydinosaurlovelydinosaur mentioned this pull request Aug 21, 2020
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Public API tightening

2 participants

@florimondmanca@jcugat