From: Olivia.Zhan Date: Tue, 16 Jul 2019 08:48:53 +0000 (+0800) Subject: Fix restcall authorization issue X-Git-Tag: 1.0.5~64 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=modeling%2Fetsicatalog.git;a=commitdiff_plain;h=2c3b00a3a4a795ca785bfb3e987f26e42a569d13 Fix restcall authorization issue Issue-ID: VFC-1429 Signed-off-by: Olivia.Zhan Change-Id: I3ab25ae88642b726452bf5f1f516479baf31bd5c --- diff --git a/genericparser/pub/utils/restcall.py b/genericparser/pub/utils/restcall.py index c83f69d..5efa0cb 100644 --- a/genericparser/pub/utils/restcall.py +++ b/genericparser/pub/utils/restcall.py @@ -18,6 +18,7 @@ import logging import urllib import uuid import httplib2 +import base64 from genericparser.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)