class_docstr: Base class for different types of credentials
  
  Note: While subclasses can define their own `_FIELDS`, they are actually
  assumed to have particular keys by the implementation of (some)
  authenticators. `HTTPRequestsAuthenticator` and its subclasses for example,
  assume `user` and `password` to be valid keys.
class_docstr_tok: ["Base","class","for","different","types","of","credentials","Note",":","While","subclasses","can","define","their","own","`","_FIELDS","`",",","they","are","actually","assumed","to","have","particular","keys","by","the","implementation","of","(","some",")","authenticators",".","`","HTTPRequestsAuthenticator","`","and","its","subclasses","for","example",",","assume","`","user","`","and","`","password","`","to","be","valid","keys","."]
docstr: Set URL/dataset context after instantiation
  
  ATM by design the system of providers+downloaders+credentials doesn't
  necessarily provide access to that information at instantiation time of
  `Credential` objects. Hence, allow to provide this whenever we can.
  
  Arguments are only applied if provided. Hence, `None` does not overwrite
  a possibly already existing attribute.
  
  Note
  ----
  Eventually, this is going to need a major overhaul. `Providers` etc. are
  built to be mostly unaware of their context, which is why
  `get_dataset_root()` tends to be the only way of assessing what dataset
  we are operating on. This will, however, fail to detect the correct
  dataset, if it can'T be deduced from PWD, though.
  
  Parameters
  ----------
  auth_url : str, optional
      URL string this credential is going to be used with. This context
      may be needed to query some credential systems (like git-credential).
  dataset : str, Path or Dataset, optional
      The dataset datalad is operating on with this credential. This may
      be needed for context in order to query local configs.
code: def set_context(self, auth_url=None, dataset=None):
      """Set URL/dataset context after instantiation
  
      ATM by design the system of providers+downloaders+credentials doesn't
      necessarily provide access to that information at instantiation time of
      `Credential` objects. Hence, allow to provide this whenever we can.
  
      Arguments are only applied if provided. Hence, `None` does not overwrite
      a possibly already existing attribute.
  
      Note
      ----
      Eventually, this is going to need a major overhaul. `Providers` etc. are
      built to be mostly unaware of their context, which is why
      `get_dataset_root()` tends to be the only way of assessing what dataset
      we are operating on. This will, however, fail to detect the correct
      dataset, if it can'T be deduced from PWD, though.
  
      Parameters
      ----------
      auth_url : str, optional
          URL string this credential is going to be used with. This context
          may be needed to query some credential systems (like git-credential).
      dataset : str, Path or Dataset, optional
          The dataset datalad is operating on with this credential. This may
          be needed for context in order to query local configs.
      """
  
      # TODO: change of context should probably not be allowed. When context
      #       is actually needed for a particular credential store, this
      #       object represents such associated creds.
      #       Allowing to switch context within the same instance leads to
      #       trouble determining when exactly a reload is needed and what is
      #       to be overwritten or not.
  
      if auth_url:
          self.auth_url = auth_url
      if isinstance(dataset, Dataset):
          self.ds = dataset
      else:
          self.ds = Dataset(dataset) if dataset else None
  
imports: import time
  from ..support.exceptions import AccessDeniedError, CapturedException
  from ..support.keyring_ import keyring
  from ..ui import ui
  from ..utils import auto_repr
  from ..support.network import iso8601_to_epoch
  from datalad import cfg
  from datalad.config import anything2bool
  from datalad.distribution.dataset import Dataset
  from datalad.local.gitcredential import GitCredentialInterface
  from logging import getLogger
label_desc: Use image node_id 13 for calling the Credential obj's underlying member method code with example usage: obj.set_context(auth_url, dataset) without return types