summaryrefslogtreecommitdiff
path: root/glanceclient/common/http.py
diff options
context:
space:
mode:
authorkairat_kushaev <kkushaev@mirantis.com>2016-03-30 08:49:24 +0300
committerkairat_kushaev <kkushaev@mirantis.com>2016-03-30 13:33:19 +0300
commit2561e4061c375982fd056af583233c4c658b139e (patch)
tree20af81c9deaf8fc78ae5149d6d65068106cdcb63 /glanceclient/common/http.py
parent04e1ea73a5159f07eac5bf6ef40f33e7f724f901 (diff)
downloadpython-glanceclient-2561e4061c375982fd056af583233c4c658b139e.tar.gz
Update auth_token before sending request
Previously auth_token was initialized once in __init__ method. After that we stored token in session headers. So to refresh token users need to instantiate a new session inside http client or re-create client itself. In order to provide possibility to refresh token we need to add token header before sending the request. So users can just update auth_token attribute in the HTTPClient to refresh user token. Change-Id: Ifebe9011870bbddc46fc6d6a26563641d5559e97 Closes-Bug: #1563495
Diffstat (limited to 'glanceclient/common/http.py')
-rw-r--r--glanceclient/common/http.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/glanceclient/common/http.py b/glanceclient/common/http.py
index 1157381..4549669 100644
--- a/glanceclient/common/http.py
+++ b/glanceclient/common/http.py
@@ -124,10 +124,6 @@ class HTTPClient(_BaseHTTPClient):
self.session = requests.Session()
self.session.headers["User-Agent"] = USER_AGENT
- if self.auth_token:
- self.session.headers["X-Auth-Token"] = encodeutils.safe_encode(
- self.auth_token)
-
if self.language_header:
self.session.headers["Accept-Language"] = self.language_header
@@ -226,6 +222,10 @@ class HTTPClient(_BaseHTTPClient):
data = self._set_common_request_kwargs(headers, kwargs)
+ # add identity header to the request
+ if not headers.get('X-Auth-Token'):
+ headers['X-Auth-Token'] = self.auth_token
+
if osprofiler_web:
headers.update(osprofiler_web.get_trace_id_headers())