From: Olivia.Zhan Date: Tue, 16 Jul 2019 08:47:44 +0000 (+0800) Subject: Fix restcall authorization issue X-Git-Tag: 1.3.4~9 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F03%2F91503%2F1;p=vfc%2Fnfvo%2Fcatalog.git Fix restcall authorization issue Issue-ID: VFC-1429 Signed-off-by: Olivia.Zhan Change-Id: I5bc181eb35b49b7f6886c46237583350a1320830 --- 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)