# keystoneauth1.http_basic module

class keystoneauth1.http_basic.HTTPBasicAuth(endpoint: str | None = None, username: str | None = None, password: str | None = None)

  Bases: `FixedEndpointPlugin`

  A provider that will always use HTTP Basic authentication.

  This is useful to unify session/adapter loading for services that might be deployed in standalone mode.

  __annotate_func__ = None
  __annotations_cache__ = {'_discovery_cache': 'dict[str, discover.Discover]'}
  __doc__ = 'A provider that will always use HTTP Basic authentication.\n\nThis is useful to unify session/adapter loading for services\nthat might be deployed in standalone mode.\n'
  __firstlineno__ = 24
  __init__(endpoint: str | None = None, username: str | None = None, password: str | None = None)
  __module__ = 'keystoneauth1.http_basic'
  __static_attributes__ = ('password', 'username')
  get_headers(session: ks_session.Session) → dict[str, str] | None

    Fetch authentication headers for message.

    This is a more generalized replacement of the older get_token to allow plugins to specify different or additional authentication headers to the OpenStack standard ‘X-Auth-Token’ header.

    How the authentication headers are obtained is up to the plugin. If the headers are still valid they may be re-used, retrieved from cache or the plugin may invoke an authentication request against a server.

    The default implementation of get_headers calls the get_token method to enable older style plugins to continue functioning unchanged. Subclasses should feel free to completely override this function to provide the headers that they want.

    Returning None will indicate that no token was able to be retrieved and that authorization was a failure. Adding no authentication data can be achieved by returning an empty dictionary.

    Parameters:

      session (keystoneauth1.session.Session) – The session object that the auth_plugin belongs to.

    Returns:

      Headers that are set to authenticate a message or None for failure. Note that when checking this value that the empty dict is a valid, non-failure response.

    Return type:

      dict

  get_token(session: ks_session.Session) → str | None

    Obtain a token.

    How the token is obtained is up to the plugin. If it is still valid it may be re-used, retrieved from cache or invoke an authentication request against a server.

    Returning None will indicate that no token was able to be retrieved.

    This function is misplaced as it should only be required for auth plugins that use the ‘X-Auth-Token’ header. However due to the way plugins evolved this method is required and often called to trigger an authentication request on a new plugin.

    When implementing a new plugin it is advised that you implement this method, however if you don’t require the ‘X-Auth-Token’ header override the get_headers method instead.

    Parameters:

      session (keystoneauth1.session.Session) – A session object so the plugin can make HTTP calls.

    Returns:

      A token to use.

    Return type:

      string

this page last updated: 2026-03-25 21:01:07

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.

found an error? report a bug