3232X_WATSON_AUTHORIZATION_TOKEN = 'X-Watson-Authorization-Token'
3333AUTH_HEADER_DEPRECATION_MESSAGE = 'Authenticating with the X-Watson-Authorization-Token header is deprecated. The token continues to work with Cloud Foundry services, but is not supported for services that use Identity and Access Management (IAM) authentication.'
3434ICP_PREFIX = 'icp-'
35- USERNAME_FOR_ICP = 'apikey'
35+ APIKEY = 'apikey'
3636
3737# Uncomment this to enable http debugging
3838# try:
@@ -242,11 +242,11 @@ def __init__(self, vcap_services_name, url, username=None, password=None,
242242
243243 if api_key is not None :
244244 if api_key .startswith (ICP_PREFIX ):
245- self .set_username_and_password (USERNAME_FOR_ICP , api_key )
245+ self .set_username_and_password (APIKEY , api_key )
246246 else :
247247 self .set_api_key (api_key )
248248 elif username is not None and password is not None :
249- if username in ( 'apikey' , 'apiKey' ) :
249+ if username is APIKEY :
250250 self .set_token_manager (password , iam_access_token , iam_url )
251251 else :
252252 self .set_username_and_password (username , password )
@@ -264,11 +264,7 @@ def __init__(self, vcap_services_name, url, username=None, password=None,
264264 if 'password' in self .vcap_service_credentials :
265265 self .password = self .vcap_service_credentials ['password' ]
266266 if 'apikey' in self .vcap_service_credentials :
267- if self .vcap_service_credentials ['apikey' ].startswith (ICP_PREFIX ):
268- self .username = USERNAME_FOR_ICP
269- self .password = self .vcap_service_credentials ['apikey' ]
270- else :
271- self .api_key = self .vcap_service_credentials ['apikey' ]
267+ self .api_key = self .vcap_service_credentials ['apikey' ]
272268 if 'api_key' in self .vcap_service_credentials :
273269 self .api_key = self .vcap_service_credentials ['api_key' ]
274270 if ('iam_apikey' or 'apikey' ) in self .vcap_service_credentials :
@@ -298,7 +294,7 @@ def set_api_key(self, api_key):
298294 if api_key == 'YOUR API KEY' :
299295 api_key = None
300296 if api_key .startswith (ICP_PREFIX ):
301- self .set_username_and_password (USERNAME_FOR_ICP , api_key )
297+ self .set_username_and_password (APIKEY , api_key )
302298
303299 self .api_key = api_key
304300
0 commit comments