Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JWT in session file not honored #119

Open
higgins opened this issue Jun 9, 2022 · 0 comments
Open

JWT in session file not honored #119

higgins opened this issue Jun 9, 2022 · 0 comments

Comments

@higgins
Copy link

higgins commented Jun 9, 2022

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:

  1. If session_file exists, parse it for the jwt and pass that and session_file to duolingo.Duolingo instantiation. Explicitly setting password=None
  2. 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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant