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

Unable to retrieve anything from Duolingo ... #64

Closed
swa72 opened this issue Feb 18, 2023 · 16 comments
Closed

Unable to retrieve anything from Duolingo ... #64

swa72 opened this issue Feb 18, 2023 · 16 comments

Comments

@swa72
Copy link

swa72 commented Feb 18, 2023

What used to work, now shows ...

2023-02-18 11_56_31-

@JASchilz
Copy link
Owner

JASchilz commented Feb 18, 2023 via email

@JASchilz
Copy link
Owner

OK. It looks like something has changed in Duolingo which has broken this plugin. They may have added some extra security that rejects requests that aren't coming from their own web page or mobile apps.

This plugin uses a third party code library to interact with Duolingo, and other users of that library are reporting similar issues which started in the last couple of days in the following issue KartikTalwar/Duolingo#128 .

Right now it's not clear if:

  1. this is a small, incidental change by Duolingo
  2. or if it's maybe a change to deliberately stop people who are trying to interact with Duolingo outside of their own web page and mobile apps.

I'm going to investigate more today. If it's case (1) then I might be able to make a fix. If it's (2) then our days of AnkiSyncDuolingo might be at an end. :( In either case, thanks for bringing up this issue and if I can't fix it then I'll prominently post that in the description of the plugin.

@JASchilz JASchilz pinned this issue Feb 20, 2023
@jameskraus
Copy link
Contributor

I think this can be worked around. First, I don't think this layer of security is actually doing anything at the moment. I was able to successfully submit this as a request and get a valid JWT back:

POST /2017-06-30/login?fields= HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 102
Content-Type: application/json
Host: www.duolingo.com
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36

{
    "identifier": "my@email.com",
    "password": "<my-password>",
    "signal": {
        "token": "-",
        "vendor": 2
    }
}

The user-agent header appeared to be required, so I just used the one from my browser. I also found the above was the minimal input I could use and still get a valid JWT at the end.

I'm not entirely sure this is replicable though. I attempted to hack it into the add on, but I didn't have success and experienced an opaque error message. Maybe I just did something wrong, maybe my experiments with cURL don't translate to python requests, or maybe there's just gremlins in the code.

Long term, it also appears scraping the credentials from a login is a viable route. There's a few different ways to make it easier to grab a JWT from a given Duolingo session so we can make the request. Here's some rough ideas:

  • Create a Chrome extension specifically for grabbing the JWT from an active Duolingo session
  • Embed a QWebBrowser and scrape a JWT out of that after the user logs in

I would recommend the second approach, since it's pretty natural to log into Duolingo for end users and would be resilient against further changes to the login API. Obviously more work that just pasting in a JWT though.

@JASchilz: Could you try the above request format and see if it works for you?

@jameskraus
Copy link
Contributor

jameskraus commented Feb 21, 2023

@JASchilz, I opened a PR which allows for inputting the JWT instead of a password: #65. If the workaround in my above message doesn't work for you, then maybe this is a potential route forward. The copy is pretty poor / technical, so would obviously need tweaking on instructions.

@JASchilz
Copy link
Owner

JASchilz commented Feb 21, 2023 via email

@jameskraus
Copy link
Contributor

jameskraus commented Feb 21, 2023

@JASchilz: I opened a proof of concept PR which authenticates with an embedded QWebEngineView. It would need polish around the edges (refactoring, instructions for users, etc) but demonstrates the general idea. See #66

@JASchilz
Copy link
Owner

Hi folks including @swa72 ! I've created a release candidate from @jameskraus's pull request, which beautifully addresses this problem on my own machine.

You can install the plugin manually from https://github.com/JASchilz/AnkiSyncDuolingo/releases/tag/2.1.0rc1 . I'll make a couple of additional help/documentation changes and perform a full release on the Anki site within the next week.

@Exkywor
Copy link

Exkywor commented Mar 4, 2023

I tried 2.1.0rc1, but it doesn't seem to be working for accounts created with Google.
I tried logging in with a password, but then Duolingo says my account was created with Google, so I click on "Continue with Google", and... nothing happens. If, on the other hand, instead of trying to log in with a password I click on "Google", it says "We’re having trouble connecting. Please try again later.".

@JASchilz
Copy link
Owner

JASchilz commented Mar 5, 2023

Hi @Exkywor , thanks for trying this out and letting me know.

I tried logging in with a password

To confirm, is it the case that you've created a password with Duolingo (separate from your Google account credentials) and the site is telling you to log in with Google?

If you haven't, could you try creating a password at https://www.duolingo.com/settings/password and logging in with that?

@JASchilz
Copy link
Owner

JASchilz commented Mar 6, 2023

OK! I've published a new released on Ankiweb from the embedded-auth branch. I added a minimum of documentation/warnings to let users know that they have to log in with their Duolingo credentials and that they might encounter problems.

I did confirm that I also wasn't able to log in using Google, like @Exkywor, but I'm still curious to know if you found a way to log in with Duolingo username/password.

Over the next week or so, I'm going to clean things up like some orphan code and an error message that you get if you close the log in browser. Thanks again to everyone reporting the issue and @jameskraus for providing a solution.

I'll keep this issue open until I'm sure that we have a clean log in path for all users.

@Exkywor
Copy link

Exkywor commented Mar 7, 2023

To confirm, is it the case that you've created a password with Duolingo (separate from your Google account credentials) and the site is telling you to log in with Google?

That is the case, yeah. I created my account with Google, and later added a password, with which I tried logging in, which is when it told me that my account was created with Google.
However, I tried again today just in case, and it seems to have gone through without issues?

@jameskraus
Copy link
Contributor

jameskraus commented Mar 7, 2023 via email

@swa72
Copy link
Author

swa72 commented Mar 18, 2023

While login now works thanks to the fix ... can anyone confirm that you can pull new vocabulary? I've recently finished one and started another section. Yet, the add-on reports no new vocabulary to pull.

@JASchilz
Copy link
Owner

Hi @swa72 ! I confirm that I'm able to pull new vocabulary in the sense of:

  • I've got an Anki profile that I use just for testing this plugin.
  • When I delete all of the cards that I've imported into that plugin, and re-run the plugin.
  • It pulls down all of my existing cards.

So it works in that sense, but I haven't studied anything new and then imported that using the plugin, as I'm not currently studying with Duolingo.

Let us know if this helps you diagnose your case, or leaves open some questions. And as always, the plugin will import from the language that you most recently had open on the Duolingo site.

@swa72
Copy link
Author

swa72 commented Mar 23, 2023

Ok, have to correct myself. Having completed yet another section, it did pull down new vocabulary. No idea, why it didn't before ;-) Thanks for your effort.

@swa72 swa72 closed this as completed Mar 23, 2023
@potchy
Copy link

potchy commented May 7, 2023

Confirmed that it's not working with accounts created via Facebook even if you have a proper password set-up.

@JASchilz JASchilz unpinned this issue Mar 18, 2024
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

5 participants