@@ -20,8 +20,8 @@ def __init__(self, client_id, client_secret, api_host, use_https, logger, reques
20
20
self .clientId = client_id
21
21
self .clientSecret = client_secret
22
22
self .logger = logger
23
- self ._renew_access_token ()
24
23
self .request_timeout = request_timeout
24
+ self ._renew_access_token ()
25
25
26
26
@staticmethod
27
27
def _build_apihost (host , use_https ):
@@ -84,8 +84,13 @@ def request(self, url, method, headers, params=None, body=None):
84
84
85
85
def _renew_access_token (self ):
86
86
self .logger .debug ("Renewing Access Token" )
87
- url = self .apiHost + '/oauth/token?grant_type=client_credentials'
88
- response = requests .post (url = url , auth = HTTPBasicAuth (self .clientId , self .clientSecret ))
87
+ request_args = {'method' : HTTPMethod .POST ,
88
+ 'url' : self .apiHost + '/oauth/token?grant_type=client_credentials' ,
89
+ 'auth' : HTTPBasicAuth (self .clientId , self .clientSecret )}
90
+ if self .request_timeout :
91
+ request_args ['timeout' ] = self .request_timeout
92
+
93
+ response = requests .request (** request_args )
89
94
if response .status_code == requests .codes .OK :
90
95
self .access_token = response .json ()['access_token' ]
91
96
self .token_expiration = self ._extract_expiration (self .access_token )
0 commit comments