@@ -27,9 +27,9 @@ class APIResourceClient(object):
2727 def logged_curl (self , method , url , params ):
2828 dict_params = self .to_dict (params )
2929 self .log_request (method , url , params , dict_params )
30- rbody , rcode , _ = clever .APIRequestor ().request_raw (method , url , dict_params )
31- self .log_result (rbody , rcode )
32- return rbody , rcode
30+ res , auth = clever .APIRequestor ().request_raw (method , url , dict_params )
31+ self .log_result (res [ 'body' ], res [ 'code' ] )
32+ return res [ 'body' ], res [ 'code' ]
3333
3434 def log_request (self , method , url , ordered_params , dict_params ):
3535 if method .lower () == 'get' :
@@ -46,7 +46,9 @@ class APIResourceClient(object):
4646 term = ' \\ '
4747 else :
4848 term = ''
49- curl = ['curl %s%s -H "Authorization: Basic %s"%s' % (clever .api_base , url , base64 .b64encode (clever .api_key ), term )]
49+ api_key = clever .get_api_key ()
50+ curl = ['curl %s%s -H "Authorization: Basic %s"%s' %
51+ (clever .api_base , url , base64 .b64encode (api_key ), term )]
5052 if isinstance (ordered_params , list ):
5153 for i , (k , v ) in enumerate (ordered_params ):
5254 if i == len (ordered_params ) - 1 :
@@ -170,11 +172,11 @@ event
170172
171173 klass_name = args [0 ]
172174 method_name = args [1 ]
173-
174- clever .api_key = opts .api_key or os .environ .get ('CLEVER_API_KEY' )
175- if not clever .api_key :
175+ api_key = opts .api_key or os .environ .get ('CLEVER_API_KEY' )
176+ if not api_key :
176177 parser .error ('No API key provided (use -k option or set the CLEVER_API_KEY environment variable' )
177178 return 1
179+ clever .set_api_key (api_key )
178180
179181 if opts .api_base :
180182 clever .api_base = opts .api_base
0 commit comments