Skip to content

Support DigestAuth with "x-www-authenticate" in first response header #3307

Closed Answered by kiryph
kiryph asked this question in General
Discussion options

You must be logged in to vote

Here is a custom DigestAuthX for httpx. It is copy and paste of the original DigestAuth contained in httpx, simply modified the handling of the authenticate response header by adding the prefix X- to the authentication key.

MWE:

$ pipenv install httpx
$ touch auth.py test.py
.
├── Pipfile
├── Pipfile.lock
├── auth.py
└── test.py
auth.py

# modified copy of DigestAuth from https://github.com/encode/httpx/blob/master/httpx/_auth.py
from __future__ import annotations

import hashlib
import os
import re
import time
import typing
from base64 import b64encode
from urllib.request import parse_http_list

from httpx._exceptions import ProtocolError
from httpx._models import Cookies, Request, Resp…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@tomchristie
Comment options

@kiryph
Comment options

@tomchristie
Comment options

@kiryph
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by tomchristie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #3306 on September 19, 2024 14:26.