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
f43a37f7
Commit
f43a37f7
authored
4 years ago
by
kosted
Browse files
Options
Downloads
Patches
Plain Diff
add json body
parent
28f059f0
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
+17
-4
17 additions, 4 deletions
maap-s3.py
with
17 additions
and
4 deletions
maap-s3.py
+
17
−
4
View file @
f43a37f7
...
...
@@ -6,7 +6,9 @@ import os
# Import getopt module
import
getopt
oauth_token
=
os
.
getenv
(
"
BEARER_TOKEN
"
)
MAAP_ENV_TYPE
=
os
.
getenv
(
"
MAAP_ENV_TYPE
"
)
CLIENT_ID
=
os
.
getenv
(
"
CLIENT_ID
"
)
BEARER
=
""
USER_INFO_FILE_PATH
=
"
maap-s3-userinfo.json
"
userinfo
=
{}
...
...
@@ -28,19 +30,30 @@ def display_help():
#########################
def
init
():
if
os
.
path
.
isfile
(
USER_INFO_FILE_PATH
):
print
(
"
File exists
"
)
print
(
"
[INFO] Personal user info is find
"
)
else
:
print
(
"
File not exists
"
)
print
(
"
[INFO] Personal user info is not found
"
)
email
=
input
(
"
Your email:
"
)
#password
password
=
input
(
"
Your password:
"
)
userinfo
[
'
info
'
]
=
[]
#Create a json with email and password
userinfo
[
'
info
'
].
append
({
'
email
'
:
email
,
'
password
'
:
password
})
print
(
userinfo
)
print
(
"
[INFO] Start retrieving token for authent
"
)
#Set the bearer
url
=
"
https://iam.
"
+
MAAP_ENV_TYPE
.
lower
()
+
"
.esa-maap.org/oxauth/restv1/token
"
print
(
url
)
print
(
CLIENT_ID
)
response
=
requests
.
post
(
url
,
json
=
{
'
client_id
'
:
CLIENT_ID
,
'
username
'
:
email
,
'
password
'
:
password
,
"
grant_type
"
:
"
password
"
,
"
scope
"
:
"
openid+profile
"
})
print
(
response
.
text
)
print
(
response
)
#add the json in the file
with
open
(
USER_INFO_FILE_PATH
,
'
w
'
)
as
outfile
:
json
.
dump
(
userinfo
,
outfile
)
#f = open(USER_INFO_FILE_PATH, "a")
#f.write(email)
#f.write(password)
...
...
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