def openid_url_to_scheme_credential(
    openid_url: str, scopes: List[str], credential_dict: Dict[str, Any]
) -> Tuple[OpenIdConnectWithConfig, AuthCredential]:
  """Constructs OpenID scheme and credential from OpenID URL, scopes, and credential dictionary.

  Fetches OpenID configuration from the provided URL.

  Args:
      openid_url: The OpenID Connect discovery URL.
      scopes: List of scopes to be used.
      credential_dict: Dictionary containing credential information, must
        include at least "client_id" and "client_secret", may optionally include
        "redirect_uri" and "scope"

  Returns:
      Tuple: (AuthScheme, AuthCredential)

  Raises:
      ValueError: If the OpenID URL is invalid, fetching fails, or required
        fields are missing.
      requests.exceptions.RequestException:  If there's an error during the
          HTTP request.
  """
  try:
    response = requests.get(openid_url, timeout=10)
    response.raise_for_status()
    config_dict = response.json()
  except requests.exceptions.RequestException as e:
    raise ValueError(
        f"Failed to fetch OpenID configuration from {openid_url}: {e}"
    ) from e
  except ValueError as e:
    raise ValueError(
        "Invalid JSON response from OpenID configuration endpoint"
        f" {openid_url}: {e}"
    ) from e

  # Add openIdConnectUrl to config dict
  config_dict["openIdConnectUrl"] = openid_url

  return openid_dict_to_scheme_credential(config_dict, scopes, credential_dict)
Constructs OpenID scheme and credential from OpenID URL, scopes, and credential dictionary.

  Fetches OpenID configuration from the provided URL.

  Args:
      openid_url: The OpenID Connect discovery URL.
      scopes: List of scopes to be used.
      credential_dict: Dictionary containing credential information, must
        include at least "client_id" and "client_secret", may optionally include
        "redirect_uri" and "scope"

  Returns:
      Tuple: (AuthScheme, AuthCredential)

  Raises:
      ValueError: If the OpenID URL is invalid, fetching fails, or required
        fields are missing.
      requests.exceptions.RequestException:  If there's an error during the
          HTTP request.
  
src/google/adk/tools/openapi_tool/auth/auth_helpers.py