Skip to content
Snippets Groups Projects
Commit f43a37f7 authored by kosted's avatar kosted
Browse files

add json body

parent 28f059f0
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment