def token_to_scheme_credential(
    token_type: Literal["apikey", "oauth2Token"],
    location: Optional[Literal["header", "query", "cookie"]] = None,
    name: Optional[str] = None,
    credential_value: Optional[str] = None,
) -> Tuple[AuthScheme, AuthCredential]:
  """Creates a AuthScheme and AuthCredential for API key or bearer token.

  Examples:
  ```
  # API Key in header
  auth_scheme, auth_credential = token_to_scheme_credential("apikey", "header",
  "X-API-Key", "your_api_key_value")

  # API Key in query parameter
  auth_scheme, auth_credential = token_to_scheme_credential("apikey", "query",
  "api_key", "your_api_key_value")

  # OAuth2 Bearer Token in Authorization header
  auth_scheme, auth_credential = token_to_scheme_credential("oauth2Token",
  "header", "Authorization", "your_bearer_token_value")
  ```

  Args:
      type: 'apikey' or 'oauth2Token'.
      location: 'header', 'query', or 'cookie' (only 'header' for oauth2Token).
      name: The name of the header, query parameter, or cookie.
      credential_value:  The value of the API Key/ Token.

  Returns:
      Tuple: (AuthScheme, AuthCredential)

  Raises:
      ValueError: For invalid type or location.
  """
  if token_type == "apikey":
    in_: APIKeyIn
    if location == "header":
      in_ = APIKeyIn.header
    elif location == "query":
      in_ = APIKeyIn.query
    elif location == "cookie":
      in_ = APIKeyIn.cookie
    else:
      raise ValueError(f"Invalid location for apiKey: {location}")
    auth_scheme = APIKey(**{
        "type": AuthSchemeType.apiKey,
        "in": in_,
        "name": name,
    })
    if credential_value:
      auth_credential = AuthCredential(
          auth_type=AuthCredentialTypes.API_KEY, api_key=credential_value
      )
    else:
      auth_credential = None

    return auth_scheme, auth_credential

  elif token_type == "oauth2Token":
    # ignore location. OAuth2 Bearer Token is always in Authorization header.
    auth_scheme = HTTPBearer(
        bearerFormat="JWT"
    )  # Common format, can be omitted.
    if credential_value:
      auth_credential = AuthCredential(
          auth_type=AuthCredentialTypes.HTTP,
          http=HttpAuth(
              scheme="bearer",
              credentials=HttpCredentials(token=credential_value),
          ),
      )
    else:
      auth_credential = None

    return auth_scheme, auth_credential

  else:
    raise ValueError(f"Invalid security scheme type: {type}")
Creates a AuthScheme and AuthCredential for API key or bearer token.

  Examples:
  ```
  # API Key in header
  auth_scheme, auth_credential = token_to_scheme_credential("apikey", "header",
  "X-API-Key", "your_api_key_value")

  # API Key in query parameter
  auth_scheme, auth_credential = token_to_scheme_credential("apikey", "query",
  "api_key", "your_api_key_value")

  # OAuth2 Bearer Token in Authorization header
  auth_scheme, auth_credential = token_to_scheme_credential("oauth2Token",
  "header", "Authorization", "your_bearer_token_value")
  ```

  Args:
      type: 'apikey' or 'oauth2Token'.
      location: 'header', 'query', or 'cookie' (only 'header' for oauth2Token).
      name: The name of the header, query parameter, or cookie.
      credential_value:  The value of the API Key/ Token.

  Returns:
      Tuple: (AuthScheme, AuthCredential)

  Raises:
      ValueError: For invalid type or location.
  
src/google/adk/tools/openapi_tool/auth/auth_helpers.py