Revision fe7d0186 astakosclient/astakosclient/__init__.py
b/astakosclient/astakosclient/__init__.py | ||
---|---|---|
145 | 145 |
self._ui_prefix = parsed_ui_url.path |
146 | 146 |
self.logger.debug("Got ui_prefix \"%s\"" % self._ui_prefix) |
147 | 147 |
|
148 |
oa2_service_catalog = parse_endpoints(endpoints, ep_name="astakos_oa2") |
|
149 |
self._oa2_url = \ |
|
150 |
oa2_service_catalog[0]['endpoints'][0]['publicURL'] |
|
151 |
parsed_oa2_url = urlparse.urlparse(self._oa2_url) |
|
152 |
self._oa2_prefix = parsed_oa2_url.path |
|
148 |
oauth2_service_catalog = parse_endpoints(endpoints, |
|
149 |
ep_name="astakos_oauth2") |
|
150 |
self._oauth2_url = \ |
|
151 |
oauth2_service_catalog[0]['endpoints'][0]['publicURL'] |
|
152 |
parsed_oauth2_url = urlparse.urlparse(self._oauth2_url) |
|
153 |
self._oauth2_prefix = parsed_oauth2_url.path |
|
153 | 154 |
|
154 | 155 |
def _get_value(self, s): |
155 | 156 |
assert s in ['_account_url', '_account_prefix', |
156 | 157 |
'_ui_url', '_ui_prefix', |
157 |
'_oa2_url', '_oa2_prefix']
|
|
158 |
'_oauth2_url', '_oauth2_prefix']
|
|
158 | 159 |
try: |
159 | 160 |
return getattr(self, s) |
160 | 161 |
except AttributeError: |
... | ... | |
178 | 179 |
return self._get_value('_ui_prefix') |
179 | 180 |
|
180 | 181 |
@property |
181 |
def oa2_url(self): |
|
182 |
return self._get_value('_oa2_url') |
|
182 |
def oauth2_url(self):
|
|
183 |
return self._get_value('_oauth2_url')
|
|
183 | 184 |
|
184 | 185 |
@property |
185 |
def oa2_prefix(self): |
|
186 |
return self._get_value('_oa2_prefix') |
|
186 |
def oauth2_prefix(self):
|
|
187 |
return self._get_value('_oauth2_prefix')
|
|
187 | 188 |
|
188 | 189 |
@property |
189 | 190 |
def api_usercatalogs(self): |
... | ... | |
234 | 235 |
return join_urls(self.ui_prefix, "get_services") |
235 | 236 |
|
236 | 237 |
@property |
237 |
def api_oa2_auth(self): |
|
238 |
return join_urls(self.oa2_prefix, "auth") |
|
238 |
def api_oauth2_auth(self):
|
|
239 |
return join_urls(self.oauth2_prefix, "auth")
|
|
239 | 240 |
|
240 | 241 |
@property |
241 |
def api_oa2_token(self): |
|
242 |
return join_urls(self.oa2_prefix, "token") |
|
242 |
def api_oauth2_token(self):
|
|
243 |
return join_urls(self.oauth2_prefix, "token")
|
|
243 | 244 |
|
244 | 245 |
# ---------------------------------- |
245 | 246 |
@retry_dec |
... | ... | |
925 | 926 |
body=req_body, method="POST") |
926 | 927 |
|
927 | 928 |
# -------------------------------- |
928 |
# do a POST to ``API_OA2_TOKEN`` |
|
929 |
# do a POST to ``API_OAUTH2_TOKEN``
|
|
929 | 930 |
def get_token(self, grant_type, client_id, client_secret, **body_params): |
930 | 931 |
headers = {'content-type': 'application/x-www-form-urlencoded', |
931 | 932 |
'Authorization': 'Basic %s' % b64encode('%s:%s' % |
... | ... | |
933 | 934 |
client_secret))} |
934 | 935 |
body_params['grant_type'] = grant_type |
935 | 936 |
body = urllib.urlencode(body_params) |
936 |
return self._call_astakos(self.api_oa2_token, headers=headers, |
|
937 |
return self._call_astakos(self.api_oauth2_token, headers=headers,
|
|
937 | 938 |
body=body, method="POST") |
938 | 939 |
|
939 | 940 |
|
Also available in: Unified diff