@@ -132,7 +132,8 @@ class ApiClient(object):
132132 query_params=None, header_params=None, body=None, post_params=None,
133133 files=None, response_type=None, auth_settings=None,
134134 _return_http_data_only=None, collection_formats=None,
135- _preload_content=True, _request_timeout=None, _host=None):
135+ _preload_content=True, _request_timeout=None, _host=None,
136+ _request_auth=None):
136137
137138 config = self.configuration
138139
@@ -173,7 +174,9 @@ class ApiClient(object):
173174 post_params.extend(self.files_parameters(files))
174175
175176 # auth setting
176- self.update_params_for_auth(header_params, query_params, auth_settings)
177+ self.update_params_for_auth(
178+ header_params, query_params, auth_settings,
179+ request_auth=_request_auth)
177180
178181 # body
179182 if body:
@@ -347,7 +350,8 @@ class ApiClient(object):
347350 body=None, post_params=None, files=None,
348351 response_type=None, auth_settings=None, async_req=None,
349352 _return_http_data_only=None, collection_formats=None,
350- _preload_content=True, _request_timeout=None, _host=None):
353+ _preload_content=True, _request_timeout=None, _host=None,
354+ _request_auth=None):
351355 """Makes the HTTP request (synchronous) and returns deserialized data.
352356
353357 To make an async_req request, set the async_req parameter.
@@ -377,6 +381,10 @@ class ApiClient(object):
377381 number provided, it will be total request
378382 timeout. It can also be a pair (tuple) of
379383 (connection, read) timeouts.
384+ :param _request_auth: set to override the auth_settings for an a single
385+ request; this effectively ignores the authentication
386+ in the spec for a single request.
387+ :type _request_token: dict, optional
380388 :return:
381389 If async_req parameter is True,
382390 the request will be called asynchronously.
@@ -390,7 +398,8 @@ class ApiClient(object):
390398 body, post_params, files,
391399 response_type, auth_settings,
392400 _return_http_data_only, collection_formats,
393- _preload_content, _request_timeout, _host)
401+ _preload_content, _request_timeout, _host,
402+ _request_auth)
394403
395404 return self.pool.apply_async(self.__call_api, (resource_path,
396405 method, path_params,
@@ -403,7 +412,7 @@ class ApiClient(object):
403412 collection_formats,
404413 _preload_content,
405414 _request_timeout,
406- _host))
415+ _host, _request_auth ))
407416
408417 def request(self, method, url, query_params=None, headers=None,
409418 post_params=None, body=None, _preload_content=True,
@@ -550,29 +559,45 @@ class ApiClient(object):
550559 else:
551560 return content_types[0]
552561
553- def update_params_for_auth(self, headers, querys, auth_settings):
562+ def update_params_for_auth(self, headers, querys, auth_settings,
563+ request_auth=None):
554564 """Updates header and query params based on authentication setting.
555565
556566 :param headers: Header parameters dict to be updated.
557567 :param querys: Query parameters tuple list to be updated.
558568 :param auth_settings: Authentication setting identifiers list.
569+ :param request_auth: if set, the provided settings will
570+ override the token in the configuration.
559571 """
560572 if not auth_settings:
561573 return
562574
575+ if request_auth:
576+ self._apply_auth_params(headers, querys, request_auth)
577+ return
578+
563579 for auth in auth_settings:
564580 auth_setting = self.configuration.auth_settings().get(auth)
565581 if auth_setting:
566- if auth_setting['in'] == 'cookie':
567- headers['Cookie'] = auth_setting['value']
568- elif auth_setting['in'] == 'header':
569- headers[auth_setting['key']] = auth_setting['value']
570- elif auth_setting['in'] == 'query':
571- querys.append((auth_setting['key'], auth_setting['value']))
572- else:
573- raise ApiValueError(
574- 'Authentication token must be in `query` or `header`'
575- )
582+ self._apply_auth_params(headers, querys, auth_setting)
583+
584+ def _apply_auth_params(self, headers, querys, auth_setting):
585+ """Updates the request parameters based on a single auth_setting
586+
587+ :param headers: Header parameters dict to be updated.
588+ :param querys: Query parameters tuple list to be updated.
589+ :param auth_setting: auth settings for the endpoint
590+ """
591+ if auth_setting['in'] == 'cookie':
592+ headers['Cookie'] = auth_setting['value']
593+ elif auth_setting['in'] == 'header':
594+ headers[auth_setting['key']] = auth_setting['value']
595+ elif auth_setting['in'] == 'query':
596+ querys.append((auth_setting['key'], auth_setting['value']))
597+ else:
598+ raise ApiValueError(
599+ 'Authentication token must be in `query` or `header`'
600+ )
576601
577602 def __deserialize_file(self, response):
578603 """Deserializes body to file
0 commit comments