Duolingo
Duolingo copied to clipboard
JWT in session file not honored
Thank you for this SDK!
It looks like either the jwt that is saved in the session_file
I provide is either invalid or I'm instantiating something wrong.
Here's what I'm doing:
- If
session_file
exists, parse it for thejwt
and pass that andsession_file
to duolingo.Duolingo instantiation. Explicitly settingpassword=None
- I get this error:
Traceback (most recent call last):
File "test_duolingo", line 25, in <module>
lingo = duolingo.Duolingo(username, password=None, jwt=jwt, session_file=session_file)
File "/usr/local/lib/python3.9/site-packages/duolingo.py", line 66, in __init__
self._login()
File "/usr/local/lib/python3.9/site-packages/duolingo.py", line 112, in _login
raise DuolingoException("Login failed")
duolingo.DuolingoException: Login failed
The SDK works perfectly fine if I use username/password each time I instantiate Duolingo
Here is the code:
import sys
import json
from pathlib import Path
import duolingo
username = "[REDACTED]"
password = "[REDACTED]"
session_file = "/some/absolute/path"
session = Path(session_file)
if session.is_file():
print("\033[95mUsing DuoLingo session...\033[0m")
file = open(session_file, "r")
jwt = json.load(file).get("jwt_session")
lingo = duolingo.Duolingo(username, password=None, jwt=jwt, session_file=session_file)
else:
print("\033[95mLogging into DuoLingo...\033[0m")
lingo = duolingo.Duolingo(username, password, session_file=session_file)