From 25b15596f5444ce75ce33129db49e6de0fc10207 Mon Sep 17 00:00:00 2001 From: Moritz Jung <18733473+moritzj29@users.noreply.github.com> Date: Sun, 19 May 2024 21:17:56 +0200 Subject: [PATCH] [paypal] base64 decode payload containing CSRF token --- finance_dl/paypal.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/finance_dl/paypal.py b/finance_dl/paypal.py index 3148c38..6d9c180 100644 --- a/finance_dl/paypal.py +++ b/finance_dl/paypal.py @@ -47,6 +47,7 @@ import datetime import os import time +import base64 from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import Select from selenium.webdriver.common.keys import Keys @@ -176,7 +177,8 @@ def get_csrf_token(self): self.driver.get('https://www.paypal.com/myaccount/transactions/') # Get CSRF token body_element, = self.wait_and_locate((By.ID, "__APP_DATA__")) - attribute_object = json.loads(body_element.get_attribute("innerHTML")) + data = base64.b64decode(body_element.get_attribute("innerHTML")) + attribute_object = json.loads(data) self.csrf_token = attribute_object["_csrf"] return self.csrf_token