Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
maap-s3-laptop
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
esa-common
maap-s3-laptop
Commits
d2d54224
Commit
d2d54224
authored
4 years ago
by
kosted
Browse files
Options
Downloads
Patches
Plain Diff
add function to get bearer token
parent
275c7b9c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
maap-s3.py
+25
-1
25 additions, 1 deletion
maap-s3.py
with
25 additions
and
1 deletion
maap-s3.py
+
25
−
1
View file @
d2d54224
...
...
@@ -33,6 +33,7 @@ def display_help():
print
(
'
list folder/path List data in a subfolder
'
)
print
(
'
delete path/in/S3/file.tiff Delete an existing data on S3
'
)
print
(
'
refresh Refresh credentials and password
'
)
print
(
'
token email password Return a bearer token
'
)
print
(
'
resume Resume last interrupted multipart upload
'
)
sys
.
exit
(
2
)
...
...
@@ -114,6 +115,23 @@ def generate_token(email, password):
sys
.
exit
(
2
)
################################
# Generate token and return it #
###############################
def
get_token
(
email
,
password
):
#print("[INFO] Start retrieving token for authent")
#Set the bearer
url
=
"
https://iam.
"
+
MAAP_ENV_TYPE
.
lower
()
+
"
.esa-maap.org/oxauth/restv1/token
"
response
=
requests
.
post
(
url
,
data
=
{
'
client_id
'
:
CLIENT_ID
,
'
username
'
:
email
,
'
password
'
:
password
,
"
grant_type
"
:
"
password
"
,
"
scope
"
:
"
openid+profile
"
})
#Convert the string to json to fecth access_token
data
=
json
.
loads
(
response
.
text
)
token
=
data
[
'
access_token
'
]
print
(
token
)
return
token
#########################
# Check if file is older#
#########################
...
...
@@ -481,7 +499,7 @@ argv = sys.argv[1:]
result
=
0
try
:
if
len
(
argv
)
==
0
:
display_help
()
else
:
...
...
@@ -501,6 +519,12 @@ try:
display_help
()
else
:
delete
(
argv
[
1
])
elif
argv
[
0
]
==
'
token
'
:
# Delete a data
if
len
(
argv
)
!=
3
:
display_help
()
else
:
get_token
(
argv
[
1
],
argv
[
2
])
elif
argv
[
0
]
==
'
download
'
:
# Download a data
if
len
(
argv
)
!=
3
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment