shuzijun / leetcode-editor

Do Leetcode exercises in IDE, support leetcode.com and leetcode-cn.com, to meet the basic needs of doing exercises.Support theoretically: IntelliJ IDEA PhpStorm WebStorm PyCharm RubyMine AppCode CLion GoLand DataGrip Rider MPS Android Studio
https://plugins.jetbrains.com/plugin/12132-leetcode-editor
Apache License 2.0
3.76k stars 403 forks source link

leetcode.com cannot login #97

Closed shuzijun closed 4 years ago

shuzijun commented 5 years ago

Due to the recaptcha verification code added during login, login is currently not possible and a solution is being sought. Have relevant experience and need your help.

hdlldh commented 5 years ago

It is really difficult to bypass Recaptcha verification by programming. As far as I know, one of the solutions is open a separate/embeded browser window and ask user to login manually. After successfully login, the response information including session id is loaded into the program. I am not sure if you can make the plugin work in this way. I've been using your plugin for a long time. Thank you for developing such excellent tool. Hope you will address this problem soon. Appreciate your effort on this issue.

tangdi commented 5 years ago

Can users login on web then copy token to plugin configurations, then your plugin uses that token directly?

shuzijun commented 5 years ago

@hdlldh I have tried to log in using javaFx WebView, but unfortunately, it cannot pass the authentication normally. Possible cause: content-security-policy

import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.Worker.State;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

public class Demo extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception {
       /* java.net.CookieManager manager = new java.net.CookieManager();
        java.net.CookieHandler.setDefault(manager);*/
        WebView browser = new WebView();

        WebEngine webEngine = browser.getEngine();
        webEngine.setUserAgent("Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36");
        webEngine.setJavaScriptEnabled(true);
        com.sun.javafx.webkit.WebConsoleListener.setDefaultListener(
                (webView, message, lineNumber, sourceId) -> System.out.println("Console: [" + sourceId + ":" + lineNumber + "] " + message)
        );
        webEngine.getLoadWorker().stateProperty().addListener(
                new ChangeListener<State>() {
                    public void changed(ObservableValue ov, State oldState, State newState) {
                        if (newState == State.SUCCEEDED) {
                            System.out.println(webEngine.locationProperty().toString());
                        }
                    }
                });

        webEngine.load("https://leetcode.com/accounts/login/");

        StackPane root = new StackPane();
        root.getChildren().add(browser);

        primaryStage.setScene(new Scene(root, 600, 600));
        primaryStage.show();
    }

    public static void main(String[] args) {
        System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
        launch(args);
    }
}
StevenCurran commented 5 years ago

Also having this issue, thought it may be related to the new intellij version, but looks to be this additional factor of login.

fondoger commented 5 years ago

@shuzijun I successfully logged in using JavaFX WebView, if you need, I will make a PR lately.

image
shuzijun commented 5 years ago

@fondoger Thank you for your contribution

AhmedCh commented 5 years ago

I successfully logged in using JavaFX WebView, if you need, I will make a PR lately.

@fondoger do you have the fix in a fork? I am hoping to fix the issue locally for myself while the official release gets updated

fondoger commented 5 years ago

@shuzijun @AhmedCh Dear friends, I found that it may not a good solution to use JavaFX WebView to get cookies. Due to the lack of customization of javaFx WebView, I can't set headers to make it behave like a normal web browser. The Google reCAPTCHA will always require me to do human tests. Yestoday I could log in using third party account like GitHub, but today I found my account seems to be banned due to too many abnormal logging in.

I uploaded my work to my GitHub repository. The key part is https://github.com/fondoger/leetcode-editor/commit/99ffe06ab51af813e2a99c13d2f949334ec4f147#diff-1290c8fc24ac38b4a62259f0e2f1bb97.

Let plugin users set cookies manually for US leetcode website may be a practicable solution.

shuzijun commented 5 years ago

Test solutio, Download link:

Sorry, I only have Baidu Drive, download is not friendly
branch:https://github.com/shuzijun/leetcode-editor/tree/gradle

hdlldh commented 5 years ago

Tested mac version and got "login err: natives Path is empty" when I clicked login icon.

dongfang-a commented 5 years ago

I extract the zip to C:\Users\?????\.IdeaIC2019.3\config\plugins\leetcode-editor, but not work...

shuzijun commented 5 years ago

@hdlldh Unfortunately, the dependent pandomium does not support mac, we may need JCEF. Expect the platform to support, reference.

shuzijun commented 5 years ago

@dongfang-a Try using Install Plugin from Disk,https://www.jetbrains.com/help/idea/plugins-settings.html

tian-x commented 5 years ago

Tested. Mac version, "login err: natives Path is empty". @shuzijun

shuzijun commented 5 years ago

@tian-x Unfortunately, the dependent pandomium does not support mac

hdlldh commented 5 years ago

@shuzijun I saw Pandomium has MacOS build. Does it still not work? https://github.com/dzikoysk/Pandomium/wiki/macOS-Build

shuzijun commented 5 years ago

@hdlldh Does not seem to support:https://github.com/dzikoysk/pandomium/issues/2#issuecomment-490041503

julian102 commented 5 years ago

i still can not login in ... information: 1.os macos 10.14.3 2.ide goland 2018.3.4

TaylorKanper commented 5 years ago

In vscode, you can use npm to install leetcode-cli to get cookies, and then log in to leetcode. You can read cookies in the plugin. see leetcode-cli

fondoger commented 5 years ago

In vscode, you can use npm to install leetcode-cli to get cookies, and then log in to leetcode. You can read cookies in the plugin. see leetcode-cli

@tydic-kanper The leetcode-cli has same issues. See: https://github.com/skygragon/leetcode-cli/issues

shuzijun commented 5 years ago

Test solutio, Download link: mac:url key:nenz

tian-x commented 5 years ago

Tested mac version and it worked!! Thank you!! @shuzijun

hdlldh commented 4 years ago

@shuzijun Tested mac version on IntelliJ and it worked perfectly. You are amazing. Thank you for your effort on fixing this issue.

hdlldh commented 4 years ago

@shuzijun Tested mac version on PyCharm and it caused PyCharm to quit unexpectedly when I clicked login icon. Pycharm version: 2019.3.

PranavPuranik commented 4 years ago

Hey, I am not able to log in. I am using Clion and ubuntu 18.04

anshchauhan commented 4 years ago

@shuzijun I'm not able to download the plugin from mac url provided

anshchauhan commented 4 years ago

I downloaded the latest version from here and it worked. https://github.com/shuzijun/leetcode-editor/releases/tag/v6.0-beta.1 Thank you! Intellij Ultimate: 2019.3 Mac

shijij commented 4 years ago

Could we just put the session ID input somewhere in the plugin setting page? We can login in browser and paste the session id manually as a temporarily work around

dongfang-a commented 4 years ago

That shall be a good idea, if nothing else work.

shijij commented 4 years ago

Here's the summary to get the problem solved in OSX:

  1. Uninstall leetcode-editor.

  2. Goto https://github.com/shuzijun/leetcode-editor/releases/tag/v6.0-beta.1 Download "leetcode-editor-V5.4.zip" and install plugin, click on the login button will give you an error "natives Path is empty,path: ....../natives", open that path (it's your plugin directory/leetcode-editor/natives)

  3. Goto https://github.com/shuzijun/leetcode-editor/releases/tag/v6.0-jcef-beta.1 Download "natives-mac.zip" and extract jcef_app.app to that path.

  4. Restart IDEA.

shuzijun commented 4 years ago

Could we just put the session ID input somewhere in the plugin setting page? We can login in browser and paste the session id manually as a temporarily work around

This solution is being considered, JCEF compatibility test results are poor

Kelvinson commented 4 years ago

Hi, thanks for this great software, this issue still exsits so far on my computer: OS: Ubuntu 16.04 Intelliji: IntelliJ IDEA 2019.3.1 (Ultimate Edition)

Could you please noify us when you solved this issue? Thanks!

shuzijun commented 4 years ago

@Kelvinson The new version has solved this problem. v6.0.
Login help reference LoginHelp.md

Kelvinson commented 4 years ago

@shuzijun Hi shuzijun, thanks for your quick reply, it works perfectly after I download the v6.0 release and manually install it! It would be great if you can update the plugin on the jetbrain marketplace to the latest version so others don't need to solve the login problem manually.

By the way how can I modify the default package name so it' s not leetcode.editor.en but it's just leetcode , thank you very much and wish you a best new year!

shuzijun commented 4 years ago

@Kelvinson Due to the operation to delete all files in the folder, in order to prevent the deletion of important files, this path cannot be modified

Kelvinson commented 4 years ago

Got you, thank you very much!

gz2432 commented 4 years ago

Updated via IJ Marketplace but seems OSX still not working. Went back to https://github.com/shuzijun/leetcode-editor/releases/tag/v6.0-beta.1 along with https://github.com/shuzijun/leetcode-editor/releases/tag/v6.0-jcef-beta.1 and worked again.