Home / File/ auth.py — requests Source File

auth.py — requests Source File

Architecture documentation for auth.py, a python file in the requests codebase. 14 imports, 3 dependents.

File python CoreAPI SessionLifecycle 14 imports 3 dependents 1 functions 4 classes

Entity Profile

Dependency Diagram

graph LR
  d7a739b0_e73b_9565_f5ed_5e8c24943504["auth.py"]
  ad9103ba_2c26_1ff0_c67d_e7f70c6f108c["_internal_utils.py"]
  d7a739b0_e73b_9565_f5ed_5e8c24943504 --> ad9103ba_2c26_1ff0_c67d_e7f70c6f108c
  0ab29509_59a1_1f68_fae2_146376240019["to_native_string"]
  d7a739b0_e73b_9565_f5ed_5e8c24943504 --> 0ab29509_59a1_1f68_fae2_146376240019
  655589d9_9504_8132_6277_d047dcd65486["compat.py"]
  d7a739b0_e73b_9565_f5ed_5e8c24943504 --> 655589d9_9504_8132_6277_d047dcd65486
  270696ff_2a4f_ef5b_92e8_33a79e68a2d8["cookies.py"]
  d7a739b0_e73b_9565_f5ed_5e8c24943504 --> 270696ff_2a4f_ef5b_92e8_33a79e68a2d8
  55052edd_2a43_f298_b8d3_9fb1f2641e84["extract_cookies_to_jar"]
  d7a739b0_e73b_9565_f5ed_5e8c24943504 --> 55052edd_2a43_f298_b8d3_9fb1f2641e84
  2c39b9da_e317_5e6c_bbac_8362bac2110c["utils.py"]
  d7a739b0_e73b_9565_f5ed_5e8c24943504 --> 2c39b9da_e317_5e6c_bbac_8362bac2110c
  85f754cb_6190_2351_34cb_47f7d725e66b["parse_dict_header"]
  d7a739b0_e73b_9565_f5ed_5e8c24943504 --> 85f754cb_6190_2351_34cb_47f7d725e66b
  b6135901_9a3d_4bf3_85d8_d39116671ed4["hashlib"]
  d7a739b0_e73b_9565_f5ed_5e8c24943504 --> b6135901_9a3d_4bf3_85d8_d39116671ed4
  ee4485bf_7f24_0a4f_5207_2b9a2d911e29["os"]
  d7a739b0_e73b_9565_f5ed_5e8c24943504 --> ee4485bf_7f24_0a4f_5207_2b9a2d911e29
  bf35b237_3fd1_dc85_411c_b1c073e3a773["re"]
  d7a739b0_e73b_9565_f5ed_5e8c24943504 --> bf35b237_3fd1_dc85_411c_b1c073e3a773
  d04f5b22_a751_5438_e937_aa8b0666d15e["threading"]
  d7a739b0_e73b_9565_f5ed_5e8c24943504 --> d04f5b22_a751_5438_e937_aa8b0666d15e
  17309818_1833_a3e0_d6fe_f97cb9ad6ed1["time"]
  d7a739b0_e73b_9565_f5ed_5e8c24943504 --> 17309818_1833_a3e0_d6fe_f97cb9ad6ed1
  009aac51_ed5c_c3ea_588d_73c6c4638941["warnings"]
  d7a739b0_e73b_9565_f5ed_5e8c24943504 --> 009aac51_ed5c_c3ea_588d_73c6c4638941
  e3d1fff8_9f45_0f23_d9b4_c1c23253d811["base64"]
  d7a739b0_e73b_9565_f5ed_5e8c24943504 --> e3d1fff8_9f45_0f23_d9b4_c1c23253d811
  style d7a739b0_e73b_9565_f5ed_5e8c24943504 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""
requests.auth
~~~~~~~~~~~~~

This module contains the authentication handlers for Requests.
"""

import hashlib
import os
import re
import threading
import time
import warnings
from base64 import b64encode

from ._internal_utils import to_native_string
from .compat import basestring, str, urlparse
from .cookies import extract_cookies_to_jar
from .utils import parse_dict_header

CONTENT_TYPE_FORM_URLENCODED = "application/x-www-form-urlencoded"
CONTENT_TYPE_MULTI_PART = "multipart/form-data"


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")
// ... (255 more lines)

Domain

Subdomains

Functions

Frequently Asked Questions

What does auth.py do?
auth.py is a source file in the requests codebase, written in python. It belongs to the CoreAPI domain, SessionLifecycle subdomain.
What functions are defined in auth.py?
auth.py defines 1 function(s): _basic_auth_str.
What does auth.py depend on?
auth.py imports 14 module(s): _internal_utils.py, base64, compat.py, cookies.py, extract_cookies_to_jar, hashlib, os, parse_dict_header, and 6 more.
What files import auth.py?
auth.py is imported by 3 file(s): adapters.py, models.py, sessions.py.
Where is auth.py in the architecture?
auth.py is located at src/requests/auth.py (domain: CoreAPI, subdomain: SessionLifecycle, directory: src/requests).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free