clearloop / leetcode-cli

May the code be with you 👻
MIT License
322 stars 54 forks source link

Get Password failed: NoPasswordFound #28

Closed ofey404 closed 3 years ago

ofey404 commented 3 years ago

Hey there! When I use subcommands in leetcode-cli, problem like this occurs:

$ leetcode pick 1
thread 'main' panicked at 'Get Password failed: NoPasswordFound', /home/ofey/.cargo/registry/src/github.com-1ecc6299db9ec823/leetcode-cli-0.3.2/src/plugins/chrome.rs:76:36
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

With RUST_BACKTRACE=1:

$ RUST_BACKTRACE=1 leetcode list
thread 'main' panicked at 'Get Password failed: NoPasswordFound', /home/ofey/.cargo/registry/src/github.com-1ecc6299db9ec823/leetcode-cli-0.3.2/src/plugins/chrome.rs:76:36
stack backtrace:
   0: rust_begin_unwind
             at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597/library/core/src/panicking.rs:92:14
   2: core::option::expect_none_failed
             at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597/library/core/src/option.rs:1329:5
   3: leetcode_cli::plugins::chrome::cookies
   4: leetcode_cli::plugins::leetcode::LeetCode::new
   5: leetcode_cli::cache::Cache::new
   6: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
   7: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
   8: tokio::macros::scoped_tls::ScopedKey<T>::set
   9: tokio::runtime::basic_scheduler::BasicScheduler<P>::block_on
  10: tokio::runtime::context::enter
  11: tokio::runtime::Runtime::block_on
  12: leetcode::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

My system is fedora 33 workstation, I initially login leetcode with github, and I encounter this problem.

After that, I set leetcode password, logout leetcode, clear all cookies from leetcode, then relogin with my username and password. However, this problem is still there.

Thank you for your attention ⭐

clearloop commented 3 years ago

Hey @ofey404 , would you mind trying login with cookies, it seems leetcode-cli could not read your keychain for reading the sessions of chrome directly.

Here are two ways to get sessions of leetcode.com in leetcode-cli:

  1. Read the sessions from chrome directly ( this requires the password of your os user account )
  2. Fill your session into ~/.leetcode/leetcode.toml by hand (try this)
ofey404 commented 3 years ago

Ohhhhh... So there exists a leetcode.toml in .leetcode, I create a new file and has a typo in it(leecode.toml). That's why I've tried modify it, login with session, but it seems not work.

Now everything is fine, thank you for your help! ❤️

clearloop commented 3 years ago

NOTE: Remember to login leetcode.com before we run the command leetocde ❤️

Please reopen this issue if someone meet the same issue