@@ -284,7 +284,15 @@ def clone(
284284 ),
285285 )
286286
287- def request (self , route , namespace , request_arg , request_binary , timeout = None ):
287+ def request (
288+ self ,
289+ route ,
290+ namespace ,
291+ request_arg ,
292+ request_binary ,
293+ timeout = None ,
294+ extra_headers = None ,
295+ ):
288296 """
289297 Makes a request to the Dropbox API and in the process validates that
290298 the route argument and result are the expected data types. The
@@ -304,6 +312,7 @@ def request(self, route, namespace, request_arg, request_binary, timeout=None):
304312 server. After the timeout the client will give up on
305313 connection. If `None`, will use default timeout set on
306314 Dropbox object. Defaults to `None`.
315+ :param dict extra_headers: Additional HTTP headers for this request.
307316 :return: The route's result.
308317 """
309318
@@ -338,6 +347,7 @@ def request(self, route, namespace, request_arg, request_binary, timeout=None):
338347 auth_type ,
339348 request_binary ,
340349 timeout = timeout ,
350+ extra_headers = extra_headers ,
341351 )
342352 decoded_obj_result = json .loads (res .obj_result )
343353 if isinstance (res , RouteResult ):
@@ -521,6 +531,7 @@ def request_json_string_with_retry(
521531 auth_type ,
522532 request_binary ,
523533 timeout = None ,
534+ extra_headers = None ,
524535 ):
525536 """
526537 See :meth:`request_json_object` for description of parameters.
@@ -542,6 +553,7 @@ def request_json_string_with_retry(
542553 auth_type ,
543554 request_binary ,
544555 timeout = timeout ,
556+ extra_headers = extra_headers ,
545557 )
546558 except AuthError as e :
547559 if e .error and e .error .is_expired_access_token ():
@@ -591,6 +603,7 @@ def request_json_string(
591603 auth_type ,
592604 request_binary ,
593605 timeout = None ,
606+ extra_headers = None ,
594607 ):
595608 """
596609 See :meth:`request_json_string_with_retry` for description of
@@ -611,6 +624,10 @@ def request_json_string(
611624 url = self ._get_route_url (fq_hostname , func_name )
612625
613626 headers = {"User-Agent" : self ._user_agent }
627+
628+ if extra_headers :
629+ headers .update (extra_headers )
630+
614631 auth_types = auth_type .replace (" " , "" ).split ("," )
615632 if (USER_AUTH in auth_types or TEAM_AUTH in auth_types ) and self ._oauth2_access_token :
616633 headers ["Authorization" ] = "Bearer %s" % self ._oauth2_access_token
0 commit comments