diff options
author | Olivia.Zhan <zhan.jie1@zte.com.cn> | 2019-07-16 16:47:44 +0800 |
---|---|---|
committer | Olivia.Zhan <zhan.jie1@zte.com.cn> | 2019-07-16 16:47:44 +0800 |
commit | 1e53935d5810e29b1ffd79608fd2c90cd7873a19 (patch) | |
tree | 9e50ee697208bbae6d139a5768c5d853e473fdef | |
parent | 5d3f4fa6f283f1ddfcf89a94aa43c50dc050b132 (diff) |
Fix restcall authorization issue
Issue-ID: VFC-1429
Signed-off-by: Olivia.Zhan <zhan.jie1@zte.com.cn>
Change-Id: I5bc181eb35b49b7f6886c46237583350a1320830
-rw-r--r-- | catalog/pub/utils/restcall.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/catalog/pub/utils/restcall.py b/catalog/pub/utils/restcall.py index 6a07e897..8f03259c 100644 --- a/catalog/pub/utils/restcall.py +++ b/catalog/pub/utils/restcall.py @@ -18,6 +18,7 @@ import logging import urllib import uuid import httplib2 +import base64 from catalog.pub.config.config import MSB_SERVICE_IP, MSB_SERVICE_PORT @@ -39,7 +40,7 @@ def call_req(base_url, user, passwd, auth_type, resource, method, content='', ad full_url = combine_url(base_url, resource) headers = {'content-type': 'application/json', 'accept': 'application/json'} if user: - headers['Authorization'] = 'Basic ' + ('%s:%s' % (user, passwd)).encode("base64") + headers['Authorization'] = 'Basic %s' % base64.b64encode(bytes('%s:%s' % (user, passwd), "utf-8")).decode() ca_certs = None if additional_headers: headers.update(additional_headers) |