class_docstr: OAuth2 flow for authentication using a bearer token obtained with an OAuth2 code
  flow. An instance of it would be used as a dependency.
class_docstr_tok: ["OAuth2","flow","for","authentication","using","a","bearer","token","obtained","with","an","OAuth2","code","flow",".","An","instance","of","it","would","be","used","as","a","dependency","."]
code: def __init__(
      self,
      authorizationUrl: str,
      tokenUrl: Annotated[
          str,
          Doc(
              """
                  The URL to obtain the OAuth2 token.
                  """
          ),
      ],
      refreshUrl: Annotated[
          Optional[str],
          Doc(
              """
                  The URL to refresh the token and obtain a new one.
                  """
          ),
      ] = None,
      scheme_name: Annotated[
          Optional[str],
          Doc(
              """
                  Security scheme name.
  
                  It will be included in the generated OpenAPI (e.g. visible at `/docs`).
                  """
          ),
      ] = None,
      scopes: Annotated[
          Optional[Dict[str, str]],
          Doc(
              """
                  The OAuth2 scopes that would be required by the *path operations* that
                  use this dependency.
                  """
          ),
      ] = None,
      description: Annotated[
          Optional[str],
          Doc(
              """
                  Security scheme description.
  
                  It will be included in the generated OpenAPI (e.g. visible at `/docs`).
                  """
          ),
      ] = None,
      auto_error: Annotated[
          bool,
          Doc(
              """
                  By default, if no HTTP Auhtorization header is provided, required for
                  OAuth2 authentication, it will automatically cancel the request and
                  send the client an error.
  
                  If `auto_error` is set to `False`, when the HTTP Authorization header
                  is not available, instead of erroring out, the dependency result will
                  be `None`.
  
                  This is useful when you want to have optional authentication.
  
                  It is also useful when you want to have authentication that can be
                  provided in one of multiple optional ways (for example, with OAuth2
                  or in a cookie).
                  """
          ),
      ] = True,
  ):
      if not scopes:
          scopes = {}
      flows = OAuthFlowsModel(
          authorizationCode=cast(
              Any,
              {
                  "authorizationUrl": authorizationUrl,
                  "tokenUrl": tokenUrl,
                  "refreshUrl": refreshUrl,
                  "scopes": scopes,
              },
          )
      )
      super().__init__(
          flows=flows,
          scheme_name=scheme_name,
          description=description,
          auto_error=auto_error,
      )
  
imports: from typing import Any, Dict, List, Optional, Union, cast
  from fastapi.exceptions import HTTPException
  from fastapi.openapi.models import OAuth2
  from fastapi.openapi.models import OAuthFlows
  from fastapi.param_functions import Form
  from fastapi.security.base import SecurityBase
  from fastapi.security.utils import get_authorization_scheme_param
  from starlette.requests import Request
  from starlette.status import HTTP_401_UNAUTHORIZED, HTTP_403_FORBIDDEN
  from typing_extensions import Annotated, Doc
label_desc: Use image node_id 1 to create a new OAuth2AuthorizationCodeBearer object from inherited base classes: OAuth2 with example: obj = OAuth2AuthorizationCodeBearer(authorizationUrl, tokenUrl, refreshUrl, scheme_name, scopes, description, auto_error)