Skip to content

Commit

Permalink
Fix log-in issue
Browse files Browse the repository at this point in the history
The issue was described here (yannforget#76) and a solution is implemented by modifying earthexplorer.py (https://github.com/yannforget/landsatxplore/pull/75/files)
  • Loading branch information
WortalMombat authored Apr 5, 2022
1 parent 0c3bd8f commit c1c85f0
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions landsatxplore/earthexplorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)

Expand Down

0 comments on commit c1c85f0

Please sign in to comment.