fix ESO login.  the rest of ESO needs to be repaired
@@ -230,19 +230,36 @@ class EsoClass(QueryWithLogin):
password = password_from_keyring
# Authenticate
log.info("Authenticating {0} on www.eso.org...".format(username))
+
# Do not cache pieces of the login process
login_response = self._request("GET", "https://www.eso.org/sso/login",
cache=False)
+ root = BeautifulSoup(login_response.content, 'html5lib')
+ login_input = root.find(name='input', attrs={'name':'execution'})
+ if login_input is None:
+ raise ValueError("ESO login page did not have the correct attributes.")
+ execution = login_input.get('value')
+
# login form: method=post action=login [no id]
- login_result_response = self._activate_form(
- login_response, form_index=-1, inputs={'username': username,
- 'password': password})
+ #login_result_response = self._activate_form(
+ # login_response, form_index=-1, inputs={'username': username,
+ # 'password': password})
+ login_result_response = self._request("POST", "https://www.eso.org/sso/login",
+ data={'username': username,
+ 'password': password,
+ 'execution': execution,
+ '_eventId': 'submit',
+ 'geolocation': '',
+ })
+ login_result_response.raise_for_status()
root = BeautifulSoup(login_result_response.content, 'html5lib')
- authenticated = not root.select('.error')
+ authenticated = root.find('h4').text == 'Login successful'
+
if authenticated:
log.info("Authentication successful!")
else:
log.exception("Authentication failed!")
+
# When authenticated, save password in keyring if needed
if authenticated and password_from_keyring is None and store_password:
keyring.set_password("astroquery:www.eso.org", username, password)
