import requests
import urllib.parse
# definitions
myLocation = 'de_DE'
# maybe for you 'fr_FR' but for now, i can't see country specific values (of course not, because it's just about to get the credentials for KAMEREON
myUsername = 'your_mail_adresse_at_mydacia'
myPassword = 'your_password_at_mydacia'
myVIN = 'your_vin_not_for_now_but_for_later_LOL'
# definitions, normally not needed to change
myURLkeysBase = '
https://renault-wrd-prod-1-euw1-myrapp-one.s3-eu-west-1.amazonaws.com/configuration/android/config_'
myURLkeys = myURLkeysBase+myLocation+'.json'
URLgigya = '
https://accounts.eu1.gigya.com'
# initialize = not in the loop
myUsernameURL = urllib.parse.quote(myUsername)
myPasswordURL = urllib.parse.quote(myPassword)
myURLheaders = {
"content-type": "application/json",
}
apiKeys = requests.request("GET", myURLkeys, headers=myURLheaders)
apiKeysServers = apiKeys.json()['servers']
apiKeyServerWired = {"target": apiKeysServers['wiredProd']['target'], "apikey": apiKeysServers['wiredProd']['apikey']}
apiKeyServerGigya = {"target": apiKeysServers['gigyaProd']['target'], "apikey": apiKeysServers['gigyaProd']['apikey']}
print(f"apiKeyServerWired {apiKeyServerWired}")
print(f"apiKeyServerGigya {apiKeyServerGigya}")
URLaccountMethod = '/accounts.login'
URLaccount = URLgigya+URLaccountMethod+'?loginID='+myUsernameURL+'&password='+myPasswordURL+'&apiKey='+apiKeyServerGigya["apikey"]
# loop = not for now... but you'll need to refresh the session data...
# refresh(?) session or not
URLaccountJson = requests.request("GET", URLaccount, headers=myURLheaders)
sessionGigyaToken = URLaccountJson.json()["sessionInfo"]["cookieValue"]
sessionGigyaUID = urllib.parse.quote(URLaccountJson.json()["UID"])
# get the person id with the help of the token
URLaccountInfoMethod = '/accounts.getAccountInfo'
URLaccountInfo = URLgigya+URLaccountInfoMethod
URLaccountInfoHeaders = {
'Content-Type': 'application/x-www-form-urlencoded'
}
URLaccountInfoData = {
'ApiKey': urllib.parse.quote(apiKeyServerGigya["apikey"]),
'login_token': urllib.parse.quote(sessionGigyaToken)
}
URLaccountInfoResult = requests.request("POST", URLaccountInfo, headers=URLaccountInfoHeaders, data=URLaccountInfoData)
URLaccountPersonID = URLaccountInfoResult.json()["data"]["personId"]
# get the gigya gwt token
URLaccountGwtMethod = '/accounts.getJWT'
URLaccountGwt = URLgigya+URLaccountGwtMethod
URLaccountGwtHeaders = {
'Content-Type': 'application/x-www-form-urlencoded'
}
URLaccountGwtData = {
'ApiKey': urllib.parse.quote(apiKeyServerGigya["apikey"]),
'login_token': urllib.parse.quote(sessionGigyaToken),
'fields': 'data.personId,data.gigyaDataCenter',
'expiration': 900
}
URLaccountGwtResult = requests.request("POST", URLaccountGwt, headers=URLaccountGwtHeaders, data=URLaccountGwtData)
URLaccountGWTtoken = URLaccountGwtResult.json()["id_token"]
print(f"sessionGigyaToken {sessionGigyaToken}")
print(f"URLaccountPersonID {URLaccountPersonID}")
print(f"URLaccountGWTtoken {URLaccountGWTtoken}")