10.2.6.3. Session ID Authentication Method

class pytan3.auth_methods.SessionId(http_client, session, login_timeout=5, logout_timeout=5, expires_after=295, ver_check=True, lvl='info')[source]

Bases: pytan3.auth_methods.CommonMixin, pytan3.auth_methods.AuthMethod

Method that uses session id to interact with the ‘/auth’ API.

__init__(http_client, session, login_timeout=5, logout_timeout=5, expires_after=295, ver_check=True, lvl='info')[source]

Constructor.

Parameters:
  • http_client (pytan3.http_client.HttpClient) – HTTP client.
  • session (str) – Header to pass to /auth API.
  • login_timeout (int, optional) –

    Timeout for login and validate responses in seconds.

    Defaults to: 5.

  • logout_timeout (int, optional) –

    Timeout for logout responses in seconds.

    Defaults to: 5.

  • expires_after (int, optional) –

    Life of received tokens in seconds.

    Defaults to: 295.

  • ver_check (bool, optional) –

    Perform version checks against the platform version from pytan3.api_clients.get_version() using pytan3.utils.versions.version_check_obj_req().

    Defaults to: True.

  • lvl (str, optional) –

    Logging level for this object.

    Defaults to: “info”.

classmethod get_name()[source]

Get the ref name of this class for use by load().

Returns:str
classmethod get_version_req()[source]

Get the min, max, and eq version requirements of this class.

Notes

Dict can specify keys: “vmin”, “vmax”, “veq”.

This class method gets called by pytan3.utils.versions.version_check_obj_req() to perform version checks.

Returns:dict
classmethod get_args()[source]

Get all arguments used by this class.

Returns:list
classmethod get_args_required()[source]

Get all arguments used by this class that are required.

Returns:list
classmethod get_args_secure()[source]

Get all arguments used by this class that need their prompt input hidden.

Returns:list
token

Get a token.

Notes

If CommonMixin.logged_in is False, can not login to get a new one with just a session.

If CommonMixin.expired is True, can not login to get a new one with just a session.

If CommonMixin.logged_in is True, and CommonMixin.last_used is older than CommonMixin.revalidate_after, CommonMixin.validate() to re-validate token.

If CommonMixin.validate() fails validation, can not login to get a new one with just a session.

Returns:str
login(**kwargs)[source]

Send a login request to receive a token.

Raises:exceptions.LoginError – If status code in response is not 200.
Returns:str
_abc_impl = <_abc_data object>