@@ -36,40 +36,44 @@ class Atomx(object):
3636
3737 :param str email: email address of your atomx user
3838 :param str password: password of your atomx user
39+ :param str totp: 6 digit auth token if the account has 2-factor authentication enabled.
3940 :param str api_endpoint: url for connections to the api
4041 (defaults to `https://api.atomx.com/{API_VERSION}`)
4142 :param bool save_response: If `True` save the last api response meta info
4243 (without the resource payload) in :attr:`.Atomx.last_response`. (default: `True`)
4344 :return: :class:`.Atomx` session to interact with the api
4445 """
45- def __init__ (self , email , password ,
46+ def __init__ (self , email , password , totp = None ,
4647 api_endpoint = API_ENDPOINT , save_response = True , expiration = None ):
4748 self .auth_token = None
4849 self .user = None
4950 self .api_endpoint = api_endpoint .rstrip ('/' ) + '/'
5051 self .save_response = save_response
5152 #: Contains the response of the last api call, if `save_response` was set `True`
5253 self .last_response = None
53- self .login (email , password , expiration )
54+ self .login (email , password , totp , expiration )
5455
5556 @property
5657 def _auth_header (self ):
5758 if self .auth_token :
5859 return {'Authorization' : 'Bearer ' + self .auth_token }
5960
60- def login (self , email , password , expiration = None ):
61+ def login (self , email , password , totp = None , expiration = None ):
6162 """Gets new authentication token for user ``email``.
6263
6364 This method is automatically called in :meth:`__init__` so
6465 you rarely have to call this method directly.
6566
6667 :param str email: Email to use for login.
6768 :param str password: Password to use for login.
69+ :param str totp: 6 digit auth token if the account has 2-factor authentication enabled.
6870 :param int expiration: Number of seconds that the auth token should be valid. (optional)
6971 :return: None
7072 :raises: :class:`.exceptions.InvalidCredentials` if ``email``/``password`` is wrong
7173 """
7274 json = {'email' : email , 'password' : password }
75+ if totp :
76+ json ['totp' ] = str (totp )
7377 if expiration :
7478 json ['expiration' ] = expiration
7579 r = requests .post (self .api_endpoint + 'login' , json = json )
0 commit comments