Skip to main content

OpenIdConnect

OpenID Connect authentication class. An instance of it would be used as a dependency.

Attributes

AttributeTypeDescription
modelOpenIdConnectModelAn OpenIdConnectModel instance containing the OpenID Connect URL and the security scheme description for OpenAPI documentation.
scheme_namestr = self.class.nameSecurity scheme name that will be included in the generated OpenAPI (e.g. visible at /docs).
auto_errorbool = TrueDetermines if the dependency should automatically raise an HTTP error or return None when the Authorization header is missing.

Constructor

Signature

def OpenIdConnect(
openIdConnectUrl: str,
scheme_name: str | None = None,
description: str | None = None,
auto_error: bool = True
) - > null

Parameters

NameTypeDescription
openIdConnectUrlstrThe OpenID Connect URL.
scheme_name`strNone` = None
description`strNone` = None
auto_errorbool = TrueIf True, missing credentials raise an error; if False, the dependency returns None.

Methods


make_not_authenticated_error()

@classmethod
def make_not_authenticated_error() - > [HTTPException](../../../../../exceptions/httpexception.md?sid=fastapi_exceptions_httpexception)

Creates and returns an HTTP 401 Unauthorized exception with a Bearer authentication challenge header.

Returns

TypeDescription
[HTTPException](../../../../../exceptions/httpexception.md?sid=fastapi_exceptions_httpexception)An exception object configured with a 401 status code and WWW-Authenticate header to signal missing credentials.