Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
synnefo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
itminedu
synnefo
Commits
fb7b3c0a
Commit
fb7b3c0a
authored
Nov 19, 2013
by
Sofia Papagiannaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
astakosclient: Provide call for requesting oa2 token
parent
6040de52
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
1 deletion
+37
-1
astakosclient/astakosclient/__init__.py
astakosclient/astakosclient/__init__.py
+37
-1
No files found.
astakosclient/astakosclient/__init__.py
View file @
fb7b3c0a
...
...
@@ -39,6 +39,7 @@ import logging
import
urlparse
import
urllib
import
hashlib
from
base64
import
b64encode
from
copy
import
copy
import
simplejson
...
...
@@ -144,9 +145,16 @@ class AstakosClient(object):
self
.
_ui_prefix
=
parsed_ui_url
.
path
self
.
logger
.
debug
(
"Got ui_prefix
\"
%s
\"
"
%
self
.
_ui_prefix
)
oa2_service_catalog
=
parse_endpoints
(
endpoints
,
ep_name
=
"astakos_oa2"
)
self
.
_oa2_url
=
\
oa2_service_catalog
[
0
][
'endpoints'
][
0
][
'publicURL'
]
parsed_oa2_url
=
urlparse
.
urlparse
(
self
.
_oa2_url
)
self
.
_oa2_prefix
=
parsed_oa2_url
.
path
def
_get_value
(
self
,
s
):
assert
s
in
[
'_account_url'
,
'_account_prefix'
,
'_ui_url'
,
'_ui_prefix'
]
'_ui_url'
,
'_ui_prefix'
,
'_oa2_url'
,
'_oa2_prefix'
]
try
:
return
getattr
(
self
,
s
)
except
AttributeError
:
...
...
@@ -169,6 +177,14 @@ class AstakosClient(object):
def
ui_prefix
(
self
):
return
self
.
_get_value
(
'_ui_prefix'
)
@
property
def
oa2_url
(
self
):
return
self
.
_get_value
(
'_oa2_url'
)
@
property
def
oa2_prefix
(
self
):
return
self
.
_get_value
(
'_oa2_prefix'
)
@
property
def
api_usercatalogs
(
self
):
return
join_urls
(
self
.
account_prefix
,
"user_catalogs"
)
...
...
@@ -217,6 +233,14 @@ class AstakosClient(object):
def
api_getservices
(
self
):
return
join_urls
(
self
.
ui_prefix
,
"get_services"
)
@
property
def
api_oa2_auth
(
self
):
return
join_urls
(
self
.
oa2_prefix
,
"auth"
)
@
property
def
api_oa2_token
(
self
):
return
join_urls
(
self
.
oa2_prefix
,
"token"
)
# ----------------------------------
@
retry_dec
def
_call_astakos
(
self
,
request_path
,
headers
=
None
,
...
...
@@ -877,6 +901,18 @@ class AstakosClient(object):
return
self
.
_call_astakos
(
self
.
api_memberships
,
headers
=
req_headers
,
body
=
req_body
,
method
=
"POST"
)
# --------------------------------
# do a POST to ``API_OA2_TOKEN``
def
get_token
(
self
,
grant_type
,
client_id
,
client_secret
,
**
body_params
):
headers
=
{
'Content-Type'
:
'application/x-www-form-urlencoded'
,
'Authorization'
:
'Basic %s'
%
b64encode
(
'%s:%s'
%
(
client_id
,
client_secret
))}
body_params
[
'grant_type'
]
=
grant_type
body
=
urllib
.
urlencode
(
body_params
)
return
self
.
_call_astakos
(
self
.
api_oa2_token
,
headers
=
headers
,
body
=
body
,
method
=
"POST"
)
# --------------------------------------------------------------------
# parse endpoints
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment