23
23
class Client (object ):
24
24
""" A client for accessing the Twilio API. """
25
25
26
- def __init__ (self , account_sid = None , auth_token = None , http_client = None ,
27
- environment = None ):
26
+ def __init__ (self , username = None , password = None , account_sid = None ,
27
+ http_client = None , environment = None ):
28
28
"""
29
29
Initializes the Twilio Client
30
30
31
- :param str account_sid: Account Sid to authenticate with
32
- :param str auth_token: Auth Token to authenticate with
31
+ :param str username: Username to authenticate with
32
+ :param str password: Password to authenticate with
33
+ :param str account_sid: Account Sid, defaults to Username
33
34
:param HttpClient http_client: HttpClient, defaults to Httplib2Client
34
35
:param dict environment: Environment to look for auth details, defaults to os.environ
35
36
@@ -38,15 +39,17 @@ def __init__(self, account_sid=None, auth_token=None, http_client=None,
38
39
"""
39
40
environment = environment or os .environ
40
41
41
- self .account_sid = account_sid or environment .get ('TWILIO_ACCOUNT_SID' )
42
+ self .username = username or environment .get ('TWILIO_ACCOUNT_SID' )
42
43
""" :type : str """
43
- self .auth_token = auth_token or environment .get ('TWILIO_AUTH_TOKEN' )
44
+ self .password = password or environment .get ('TWILIO_AUTH_TOKEN' )
45
+ """ :type : str """
46
+ self .account_sid = account_sid or self .username
44
47
""" :type : str """
45
48
46
- if not self .account_sid or not self .auth_token :
49
+ if not self .username or not self .password :
47
50
raise TwilioException ("Credentials are required to create a TwilioClient" )
48
51
49
- self .auth = (self .account_sid , self .auth_token )
52
+ self .auth = (self .username , self .password )
50
53
""" :type : tuple(str, str) """
51
54
self .http_client = http_client or Httplib2Client ()
52
55
""" :type : HttpClient """
0 commit comments