Home / Function/ make_not_authenticated_error() — fastapi Function Reference

make_not_authenticated_error() — fastapi Function Reference

Architecture documentation for the make_not_authenticated_error() function in oauth2.py from the fastapi codebase.

Entity Profile

Dependency Diagram

graph TD
  8eebc79f_2a8c_2a4d_ce43_d94dc5a2eaf2["make_not_authenticated_error()"]
  5023758b_9456_fafe_dbb4_30deaf7720ac["OAuth2"]
  8eebc79f_2a8c_2a4d_ce43_d94dc5a2eaf2 -->|defined in| 5023758b_9456_fafe_dbb4_30deaf7720ac
  b560ad81_87a3_a7da_6bf8_f1bf0b4190a4["__call__()"]
  b560ad81_87a3_a7da_6bf8_f1bf0b4190a4 -->|calls| 8eebc79f_2a8c_2a4d_ce43_d94dc5a2eaf2
  815c76ad_ef57_2c1a_ca86_4ca22d0bf6d5["__call__()"]
  815c76ad_ef57_2c1a_ca86_4ca22d0bf6d5 -->|calls| 8eebc79f_2a8c_2a4d_ce43_d94dc5a2eaf2
  792b0068_1314_2ef5_1e7b_e8b9a85e1c47["__call__()"]
  792b0068_1314_2ef5_1e7b_e8b9a85e1c47 -->|calls| 8eebc79f_2a8c_2a4d_ce43_d94dc5a2eaf2
  style 8eebc79f_2a8c_2a4d_ce43_d94dc5a2eaf2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

fastapi/security/oauth2.py lines 401–421

    def make_not_authenticated_error(self) -> HTTPException:
        """
        The OAuth 2 specification doesn't define the challenge that should be used,
        because a `Bearer` token is not really the only option to authenticate.

        But declaring any other authentication challenge would be application-specific
        as it's not defined in the specification.

        For practical reasons, this method uses the `Bearer` challenge by default, as
        it's probably the most common one.

        If you are implementing an OAuth2 authentication scheme other than the provided
        ones in FastAPI (based on bearer tokens), you might want to override this.

        Ref: https://datatracker.ietf.org/doc/html/rfc6749
        """
        return HTTPException(
            status_code=HTTP_401_UNAUTHORIZED,
            detail="Not authenticated",
            headers={"WWW-Authenticate": "Bearer"},
        )

Domain

Subdomains

Frequently Asked Questions

What does make_not_authenticated_error() do?
make_not_authenticated_error() is a function in the fastapi codebase, defined in fastapi/security/oauth2.py.
Where is make_not_authenticated_error() defined?
make_not_authenticated_error() is defined in fastapi/security/oauth2.py at line 401.
What calls make_not_authenticated_error()?
make_not_authenticated_error() is called by 3 function(s): __call__, __call__, __call__.

Analyze Your Own Codebase

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

Try Supermodel Free