_basic_auth_str() — requests Function Reference
Architecture documentation for the _basic_auth_str() function in auth.py from the requests codebase.
Entity Profile
Dependency Diagram
graph TD fa72bb6a_120a_ce88_fe4e_28d8c4d3b882["_basic_auth_str()"] d7a739b0_e73b_9565_f5ed_5e8c24943504["auth.py"] fa72bb6a_120a_ce88_fe4e_28d8c4d3b882 -->|defined in| d7a739b0_e73b_9565_f5ed_5e8c24943504 c8873437_03c5_1072_0f73_3ced2a7902d5["proxy_headers()"] c8873437_03c5_1072_0f73_3ced2a7902d5 -->|calls| fa72bb6a_120a_ce88_fe4e_28d8c4d3b882 cbef72a5_7ccf_3765_9a72_b2aa84bb29cb["__call__()"] cbef72a5_7ccf_3765_9a72_b2aa84bb29cb -->|calls| fa72bb6a_120a_ce88_fe4e_28d8c4d3b882 3f17a414_17be_20df_2bf2_361bb6dedc32["__call__()"] 3f17a414_17be_20df_2bf2_361bb6dedc32 -->|calls| fa72bb6a_120a_ce88_fe4e_28d8c4d3b882 37e21bd7_763f_f217_e84e_39590f4b9478["rebuild_proxies()"] 37e21bd7_763f_f217_e84e_39590f4b9478 -->|calls| fa72bb6a_120a_ce88_fe4e_28d8c4d3b882 0ab29509_59a1_1f68_fae2_146376240019["to_native_string()"] fa72bb6a_120a_ce88_fe4e_28d8c4d3b882 -->|calls| 0ab29509_59a1_1f68_fae2_146376240019 style fa72bb6a_120a_ce88_fe4e_28d8c4d3b882 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/requests/auth.py lines 25–66
def _basic_auth_str(username, password):
"""Returns a Basic Auth string."""
# "I want us to put a big-ol' comment on top of it that
# says that this behaviour is dumb but we need to preserve
# it because people are relying on it."
# - Lukasa
#
# These are here solely to maintain backwards compatibility
# for things like ints. This will be removed in 3.0.0.
if not isinstance(username, basestring):
warnings.warn(
"Non-string usernames will no longer be supported in Requests "
f"3.0.0. Please convert the object you've passed in ({username!r}) to "
"a string or bytes object in the near future to avoid "
"problems.",
category=DeprecationWarning,
)
username = str(username)
if not isinstance(password, basestring):
warnings.warn(
"Non-string passwords will no longer be supported in Requests "
f"3.0.0. Please convert the object you've passed in ({type(password)!r}) to "
"a string or bytes object in the near future to avoid "
"problems.",
category=DeprecationWarning,
)
password = str(password)
# -- End Removal --
if isinstance(username, str):
username = username.encode("latin1")
if isinstance(password, str):
password = password.encode("latin1")
authstr = "Basic " + to_native_string(
b64encode(b":".join((username, password))).strip()
)
return authstr
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does _basic_auth_str() do?
_basic_auth_str() is a function in the requests codebase, defined in src/requests/auth.py.
Where is _basic_auth_str() defined?
_basic_auth_str() is defined in src/requests/auth.py at line 25.
What does _basic_auth_str() call?
_basic_auth_str() calls 1 function(s): to_native_string.
What calls _basic_auth_str()?
_basic_auth_str() is called by 4 function(s): __call__, __call__, proxy_headers, rebuild_proxies.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free