OpenIdConnect
OpenID Connect authentication class. An instance of it would be used as a dependency.
Attributes
| Attribute | Type | Description |
|---|---|---|
| model | OpenIdConnectModel | An OpenIdConnectModel instance containing the OpenID Connect URL and the security scheme description for OpenAPI documentation. |
| scheme_name | str = self.class.name | Security scheme name that will be included in the generated OpenAPI (e.g. visible at /docs). |
| auto_error | bool = True | Determines 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
| Name | Type | Description |
|---|---|---|
| openIdConnectUrl | str | The OpenID Connect URL. |
| scheme_name | `str | None` = None |
| description | `str | None` = None |
| auto_error | bool = True | If 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
| Type | Description |
|---|---|
[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. |