From 2e11fe5e144bb412dc43ad0a684156ca2c436d56 Mon Sep 17 00:00:00 2001 From: moritzj29 <18733473+moritzj29@users.noreply.github.com> Date: Tue, 3 Sep 2024 00:35:25 +0200 Subject: [PATCH] [paypal] base64 decode payload containing CSRF token (#98) --- 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