From f7b4a19b7c0701b031952554c19853b4f192e8af Mon Sep 17 00:00:00 2001 From: Florian Bezannier Date: Sat, 30 Jan 2021 12:51:41 +0100 Subject: [PATCH] handle error in app decoder --- app_decoder.py | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/app_decoder.py b/app_decoder.py index 312355d..a6db786 100755 --- a/app_decoder.py +++ b/app_decoder.py @@ -1,6 +1,8 @@ #!/usr/bin/env python3 import json import os +import traceback + from androguard.core.bytecodes.apk import APK import requests @@ -82,20 +84,27 @@ country_code = input("What is your country code ? (ex: FR, GB, DE, ES...)\n") ## Customer id site_code="AP_"+country_code+"_ESP" -res=requests.post(HOST_BRANDID_PROD+"/GetAccessToken", - headers={ - "Connection": "Keep-Alive", - "Content-Type": "application/json", - "Host": "id-dcr.peugeot.com", - "User-Agent": "okhttp/2.3.0" - }, - params={"jsonRequest": json.dumps({"siteCode": site_code, "culture": "fr-FR", "action": "authenticate", - "fields": {"USR_EMAIL": {"value": client_email}, - "USR_PASSWORD": {"value": client_password}}}) - } - ) +try: + res = requests.post(HOST_BRANDID_PROD+"/GetAccessToken", + headers={ + "Connection": "Keep-Alive", + "Content-Type": "application/json", + "Host": "id-dcr.peugeot.com", + "User-Agent": "okhttp/2.3.0" + }, + params={"jsonRequest": json.dumps({"siteCode": site_code, "culture": "fr-FR", "action": "authenticate", + "fields": {"USR_EMAIL": {"value": client_email}, + "USR_PASSWORD": {"value": client_password}}}) + } + ) + + token = res.json()["accessToken"] +except: + traceback.print_exc() + print(f"HOST_BRANDID : {HOST_BRANDID_PROD} sitecode: {site_code}") + print(res.text) + exit(1) -token = res.json()["accessToken"] save_key_to_pem(pfx_cert,"") res2 = requests.post("https://mw-ap-m2c.mym.awsmpsa.com/api/v1/user?culture=fr_FR&width=1080&cgu=1611656517&v=1.27.0",