From c1c85f01ddbe3f985d2becf0a222c4caf90f2a36 Mon Sep 17 00:00:00 2001 From: WortalMombat <49528004+WortalMombat@users.noreply.github.com> Date: Tue, 5 Apr 2022 16:56:51 +0200 Subject: [PATCH] Fix log-in issue The issue was described here (https://github.com/yannforget/landsatxplore/issues/76) and a solution is implemented by modifying earthexplorer.py (https://github.com/yannforget/landsatxplore/pull/75/files) --- landsatxplore/earthexplorer.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/landsatxplore/earthexplorer.py b/landsatxplore/earthexplorer.py index 31d25f8..9166394 100644 --- a/landsatxplore/earthexplorer.py +++ b/landsatxplore/earthexplorer.py @@ -49,14 +49,14 @@ def _get_tokens(body): """Get `csrf_token` and `__ncforminfo`.""" csrf = re.findall(r'name="csrf" value="(.+?)"', body)[0] - ncform = re.findall(r'name="__ncforminfo" value="(.+?)"', body)[0] + # ncform = re.findall(r'name="__ncforminfo" value="(.+?)"', body)[0] if not csrf: raise EarthExplorerError("EE: login failed (csrf token not found).") - if not ncform: - raise EarthExplorerError("EE: login failed (ncforminfo not found).") + # if not ncform: + # raise EarthExplorerError("EE: login failed (ncforminfo not found).") - return csrf, ncform + return csrf#, ncform class EarthExplorer(object): @@ -76,12 +76,13 @@ def logged_in(self): def login(self, username, password): """Login to Earth Explorer.""" rsp = self.session.get(EE_LOGIN_URL) - csrf, ncform = _get_tokens(rsp.text) + #csrf, ncform = _get_tokens(rsp.text) + csrf = _get_tokens(rsp.text) payload = { "username": username, "password": password, "csrf": csrf, - "__ncforminfo": ncform, + #"__ncforminfo": ncform, } rsp = self.session.post(EE_LOGIN_URL, data=payload, allow_redirects=True)