@@ -56,7 +56,7 @@ class BaseService(object):
56
56
57
57
def __init__ (self , vcap_services_name , url , username = None , password = None ,
58
58
use_vcap_services = True , api_key = None ,
59
- iam_apikey = None , iam_access_token = None , iam_url = None ,
59
+ iam_apikey = None , iam_access_token = None , iam_url = None , iam_client_id = None , iam_client_secret = None ,
60
60
display_name = None ):
61
61
"""
62
62
It loads credentials with the following preference:
@@ -74,6 +74,8 @@ def __init__(self, vcap_services_name, url, username=None, password=None,
74
74
self .iam_apikey = None
75
75
self .iam_access_token = None
76
76
self .iam_url = None
77
+ self .iam_client_id = None
78
+ self .iam_client_secret = None
77
79
self .token_manager = None
78
80
self .verify = None # Indicates whether to ignore verifying the SSL certification
79
81
@@ -88,17 +90,17 @@ def __init__(self, vcap_services_name, url, username=None, password=None,
88
90
if api_key .startswith (self .ICP_PREFIX ):
89
91
self .set_username_and_password (self .APIKEY , api_key )
90
92
else :
91
- self .set_token_manager (api_key , iam_access_token , iam_url )
93
+ self .set_token_manager (api_key , iam_access_token , iam_url , iam_client_id , iam_client_secret )
92
94
elif username is not None and password is not None :
93
95
if username is self .APIKEY and not password .startswith (self .ICP_PREFIX ):
94
- self .set_token_manager (password , iam_access_token , iam_url )
96
+ self .set_token_manager (password , iam_access_token , iam_url , iam_client_id , iam_client_secret )
95
97
else :
96
98
self .set_username_and_password (username , password )
97
99
elif iam_access_token is not None or iam_apikey is not None :
98
100
if iam_apikey and iam_apikey .startswith (self .ICP_PREFIX ):
99
101
self .set_username_and_password (self .APIKEY , iam_apikey )
100
102
else :
101
- self .set_token_manager (iam_apikey , iam_access_token , iam_url )
103
+ self .set_token_manager (iam_apikey , iam_access_token , iam_url , iam_client_id , iam_client_secret )
102
104
103
105
# 2. Credentials from credential file
104
106
if display_name and not self .username and not self .token_manager :
@@ -196,15 +198,18 @@ def set_username_and_password(self, username, password):
196
198
self .password = password
197
199
self .jar = CookieJar ()
198
200
199
- def set_token_manager (self , iam_apikey = None , iam_access_token = None , iam_url = None ):
201
+ def set_token_manager (self , iam_apikey = None , iam_access_token = None , iam_url = None ,
202
+ iam_client_id = None , iam_client_secret = None ):
200
203
if has_bad_first_or_last_char (iam_apikey ):
201
204
raise ValueError ('The credentials shouldn\' t start or end with curly brackets or quotes. '
202
205
'Be sure to remove any {} and \" characters surrounding your credentials' )
203
206
204
- self .token_manager = IAMTokenManager (iam_apikey , iam_access_token , iam_url )
207
+ self .token_manager = IAMTokenManager (iam_apikey , iam_access_token , iam_url , iam_client_id , iam_client_secret )
205
208
self .iam_apikey = iam_apikey
206
209
self .iam_access_token = iam_access_token
207
210
self .iam_url = iam_url
211
+ self .iam_client_id = iam_client_id
212
+ self .iam_client_secret = iam_client_secret
208
213
self .jar = CookieJar ()
209
214
210
215
def set_iam_access_token (self , iam_access_token ):
0 commit comments