Skip to content

Commit a455149

Browse files
peskafBelKed
andauthored
Login update (#93)
* 2FA updates. * Revert login change. * Login update. * Login update. * Update login Update request url and split value for obtaining csrf token. * Keep the original login method as a fallback * Revert "Keep the original login method as a fallback" * Revert "Login update." --------- Co-authored-by: BelKed <66956532+BelKed@users.noreply.github.com>
1 parent 20aeb11 commit a455149

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

edupage_api/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,18 +313,19 @@ def switch_to_parent(self):
313313
Parent(self).switch_to_parent()
314314

315315
@classmethod
316-
def from_session_id(cls, session_id: str, subdomain: str):
316+
def from_session_id(cls, session_id: str, subdomain: str, username: str):
317317
"""Create an `Edupage` instance with a session id and subdomain.
318318
319319
Args:
320320
session_id (str): The `PHPSESSID` cookie.
321321
subdomain (str): Subdomain of the school which cookie is from.
322+
username (str): The username of the account this session_id is from.
322323
323324
Returns:
324325
Edupage: A new `Edupage` instance.
325326
"""
326327
instance = cls()
327328

328-
Login(instance).reload_data(subdomain, session_id)
329+
Login(instance).reload_data(subdomain, session_id, username)
329330

330331
return instance

edupage_api/login.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,12 @@ def login(
161161
or there was another problem with the second factor.
162162
"""
163163

164-
request_url = f"https://{subdomain}.edupage.org/login/index.php"
164+
request_url = f"https://{subdomain}.edupage.org/login/?cmd=MainLogin"
165165

166166
response = self.edupage.session.get(request_url)
167167
data = response.content.decode()
168168

169-
csrf_token = data.split('name="csrfauth" value="')[1].split('"')[0]
169+
csrf_token = data.split('"csrftoken":"')[1].split('"')[0]
170170

171171
parameters = {
172172
"csrfauth": csrf_token,

0 commit comments

Comments
 (0)