@@ -42,11 +42,12 @@ class BaseClient(object):
4242 def __init__ (self , client_id , client_secret ,
4343 grant_type = None , storage_class = config .TOKEN_STORAGE_CLASS ,
4444 token_uri = config .TOKEN_URI , api_uri = config .MERGADO_API_URI ,
45- retry_status_list = (500 , 502 , 503 , 504 ), tries = 3 ):
45+ retry_status_list = (500 , 502 , 503 , 504 ), tries = 3 , headers = None ):
4646
4747 self .client_id = client_id
4848 self .client_secret = client_secret
4949 self .grant_type = grant_type
50+ self .headers = headers or {}
5051
5152 self .TokenStorage = _class_from_string (storage_class )
5253 self .storage = self .TokenStorage ()
@@ -84,11 +85,18 @@ def get_url(self, path):
8485 path = path [1 :]
8586 return urljoin (self .api_uri , path )
8687
88+ def get_headers (self ):
89+ headers = {
90+ ** self ._token_headers ,
91+ ** self .headers
92+ }
93+ return headers
94+
8795 def request (self , method , path , ** options ):
8896 def make_request ():
8997 return http .request (
9098 method , self .get_url (path ),
91- headers = self ._token_headers , ** options )
99+ headers = self .get_headers () , ** options )
92100
93101 response = retry_request (
94102 make_request , self .retry_status_list , self .tries )
0 commit comments