From 1e53935d5810e29b1ffd79608fd2c90cd7873a19 Mon Sep 17 00:00:00 2001 From: "Olivia.Zhan" Date: Tue, 16 Jul 2019 16:47:44 +0800 Subject: Fix restcall authorization issue Issue-ID: VFC-1429 Signed-off-by: Olivia.Zhan Change-Id: I5bc181eb35b49b7f6886c46237583350a1320830 --- catalog/pub/utils/restcall.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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) -- cgit 1.2.3-korg