Home / Function/ __call__() — fastapi Function Reference

__call__() — fastapi Function Reference

Architecture documentation for the __call__() function in http.py from the fastapi codebase.

Entity Profile

Dependency Diagram

graph TD
  a697d1f6_bd76_670c_2a20_c42790a213a7["__call__()"]
  4e2b048a_4ece_200c_1c67_a89f28fd47db["HTTPBasic"]
  a697d1f6_bd76_670c_2a20_c42790a213a7 -->|defined in| 4e2b048a_4ece_200c_1c67_a89f28fd47db
  8a4f3cb1_2bb3_9484_ab7e_5424511db588["make_not_authenticated_error()"]
  a697d1f6_bd76_670c_2a20_c42790a213a7 -->|calls| 8a4f3cb1_2bb3_9484_ab7e_5424511db588
  21dea0a2_f30d_d3da_ce48_734fa9836d52["get_authorization_scheme_param()"]
  a697d1f6_bd76_670c_2a20_c42790a213a7 -->|calls| 21dea0a2_f30d_d3da_ce48_734fa9836d52
  style a697d1f6_bd76_670c_2a20_c42790a213a7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

fastapi/security/http.py lines 204–221

    async def __call__(  # type: ignore
        self, request: Request
    ) -> Optional[HTTPBasicCredentials]:
        authorization = request.headers.get("Authorization")
        scheme, param = get_authorization_scheme_param(authorization)
        if not authorization or scheme.lower() != "basic":
            if self.auto_error:
                raise self.make_not_authenticated_error()
            else:
                return None
        try:
            data = b64decode(param).decode("ascii")
        except (ValueError, UnicodeDecodeError, binascii.Error) as e:
            raise self.make_not_authenticated_error() from e
        username, separator, password = data.partition(":")
        if not separator:
            raise self.make_not_authenticated_error()
        return HTTPBasicCredentials(username=username, password=password)

Domain

Subdomains

Frequently Asked Questions

What does __call__() do?
__call__() is a function in the fastapi codebase, defined in fastapi/security/http.py.
Where is __call__() defined?
__call__() is defined in fastapi/security/http.py at line 204.
What does __call__() call?
__call__() calls 2 function(s): get_authorization_scheme_param, make_not_authenticated_error.

Analyze Your Own Codebase

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

Try Supermodel Free