# google-auth 2.62.0 (Apache-2.0), harvested by tools/harvest_corpus.py
=== input
Create the ID Token credentials from the current environment.

    This function acquires ID token from the environment in the following order.
    See https://google.aip.dev/auth/4110.

    1. If the environment variable ``GOOGLE_APPLICATION_CREDENTIALS`` is set
       to the path of a valid service account JSON file, then ID token is
       acquired using this service account credentials.
    2. If the application is running in Compute Engine, App Engine or Cloud Run,
       then the ID token are obtained from the metadata server.
    3. If metadata server doesn't exist and no valid service account credentials
       are found, :class:`~google.auth.exceptions.DefaultCredentialsError` will
       be raised.

    Example::

        import google.oauth2.id_token
        import google.auth.transport.requests

        request = google.auth.transport.requests.Request()
        target_audience = "https://pubsub.googleapis.com"

        # Create ID token credentials.
        credentials = google.oauth2.id_token.fetch_id_token_credentials(target_audience, request=request)

        # Refresh the credential to obtain an ID token.
        credentials.refresh(request)

        id_token = credentials.token
        id_token_expiry = credentials.expiry

    Args:
        audience (str): The audience that this ID token is intended for.
        request (Optional[google.auth.transport.Request]): A callable used to make
            HTTP requests. A request object will be created if not provided.
        bind_id_token (Optional[bool]): Controls whether to request a
            certificate-bound ID token from the metadata server identity
            endpoint. If ``True``, requests a bound token whenever a valid
            Agent Identity certificate is available and token binding is not
            disabled via ``GOOGLE_API_ENABLE_RUNTIME_BOUND_TOKEN``, falling back
            to an unbound token otherwise (or raising
            :class:`~google.auth.exceptions.RefreshError` if a configured
            certificate is not found after retries). If ``False``, always
            requests an unbound token. If ``None`` (default), token binding is
            determined automatically by the library. Set ``True`` or ``False``
            explicitly if your application requires a specific behavior. Has no
            effect when credentials are loaded from
            ``GOOGLE_APPLICATION_CREDENTIALS``.

    Returns:
        google.auth.credentials.Credentials: The ID token credentials.

    Raises:
        ~google.auth.exceptions.DefaultCredentialsError:
            If metadata server doesn't exist and no valid service account
            credentials are found.
    
=== parse google
short_description: 'Create the ID Token credentials from the current environment.'
long_description: |
  This function acquires ID token from the environment in the following order.
  See https://google.aip.dev/auth/4110.
  
  1. If the environment variable ``GOOGLE_APPLICATION_CREDENTIALS`` is set
     to the path of a valid service account JSON file, then ID token is
     acquired using this service account credentials.
  2. If the application is running in Compute Engine, App Engine or Cloud Run,
     then the ID token are obtained from the metadata server.
  3. If metadata server doesn't exist and no valid service account credentials
     are found, :class:`~google.auth.exceptions.DefaultCredentialsError` will
     be raised.
  
  Example::
  
      import google.oauth2.id_token
      import google.auth.transport.requests
  
      request = google.auth.transport.requests.Request()
      target_audience = "https://pubsub.googleapis.com"
  
      # Create ID token credentials.
      credentials = google.oauth2.id_token.fetch_id_token_credentials(target_audience, request=request)
  
      # Refresh the credential to obtain an ID token.
      credentials.refresh(request)
  
      id_token = credentials.token
      id_token_expiry = credentials.expiry
blank_after_short_description: True
blank_after_long_description: True
style: google
- DocstringParam
  description: 'The audience that this ID token is intended for.'
  kind: param
  key: 'param'
  arg_name: 'audience'
  type_name: 'str'
  is_optional: False
- DocstringParam
  description: |
    A callable used to make
    HTTP requests. A request object will be created if not provided.
  kind: param
  key: 'param'
  arg_name: 'request'
  type_name: 'Optional[google.auth.transport.Request]'
  is_optional: False
- DocstringParam
  description: |
    Controls whether to request a
    certificate-bound ID token from the metadata server identity
    endpoint. If ``True``, requests a bound token whenever a valid
    Agent Identity certificate is available and token binding is not
    disabled via ``GOOGLE_API_ENABLE_RUNTIME_BOUND_TOKEN``, falling back
    to an unbound token otherwise (or raising
    :class:`~google.auth.exceptions.RefreshError` if a configured
    certificate is not found after retries). If ``False``, always
    requests an unbound token. If ``None`` (default), token binding is
    determined automatically by the library. Set ``True`` or ``False``
    explicitly if your application requires a specific behavior. Has no
    effect when credentials are loaded from
    ``GOOGLE_APPLICATION_CREDENTIALS``.
  kind: param
  key: 'param'
  arg_name: 'bind_id_token'
  type_name: 'Optional[bool]'
  is_optional: False
- DocstringReturns
  description: 'The ID token credentials.'
  kind: returns
  key: 'returns'
  type_name: 'google.auth.credentials.Credentials'
  is_generator: False
- DocstringRaises
  description: |
    If metadata server doesn't exist and no valid service account
    credentials are found.
  kind: raises
  key: 'raises'
  type_name: '~google.auth.exceptions.DefaultCredentialsError'
=== detect
google
=== compose google
Create the ID Token credentials from the current environment.

This function acquires ID token from the environment in the following order.
See https://google.aip.dev/auth/4110.

1. If the environment variable ``GOOGLE_APPLICATION_CREDENTIALS`` is set
   to the path of a valid service account JSON file, then ID token is
   acquired using this service account credentials.
2. If the application is running in Compute Engine, App Engine or Cloud Run,
   then the ID token are obtained from the metadata server.
3. If metadata server doesn't exist and no valid service account credentials
   are found, :class:`~google.auth.exceptions.DefaultCredentialsError` will
   be raised.

Example::

    import google.oauth2.id_token
    import google.auth.transport.requests

    request = google.auth.transport.requests.Request()
    target_audience = "https://pubsub.googleapis.com"

    # Create ID token credentials.
    credentials = google.oauth2.id_token.fetch_id_token_credentials(target_audience, request=request)

    # Refresh the credential to obtain an ID token.
    credentials.refresh(request)

    id_token = credentials.token
    id_token_expiry = credentials.expiry

Args:
    audience (str): The audience that this ID token is intended for.
    request (Optional[google.auth.transport.Request]): A callable used to make
        HTTP requests. A request object will be created if not provided.
    bind_id_token (Optional[bool]): Controls whether to request a
        certificate-bound ID token from the metadata server identity
        endpoint. If ``True``, requests a bound token whenever a valid
        Agent Identity certificate is available and token binding is not
        disabled via ``GOOGLE_API_ENABLE_RUNTIME_BOUND_TOKEN``, falling back
        to an unbound token otherwise (or raising
        :class:`~google.auth.exceptions.RefreshError` if a configured
        certificate is not found after retries). If ``False``, always
        requests an unbound token. If ``None`` (default), token binding is
        determined automatically by the library. Set ``True`` or ``False``
        explicitly if your application requires a specific behavior. Has no
        effect when credentials are loaded from
        ``GOOGLE_APPLICATION_CREDENTIALS``.

Returns:
    google.auth.credentials.Credentials: The ID token credentials.

Raises:
    ~google.auth.exceptions.DefaultCredentialsError: If metadata server doesn't exist and no valid service account
        credentials are found.
