skygragon / leetcode-cli

A cli tool to enjoy leetcode!
MIT License
3.63k stars 456 forks source link

登录不上,[ERROR] session expired, please login again [-1] #94

Open Allenhua opened 6 years ago

Allenhua commented 6 years ago

如题,登陆时始终报这个错误

skygragon commented 6 years ago

please try "leetcode user -l -vv" to print more logs?

dodouwang commented 6 years ago

Sometimes succeeded sometimes failed to get a response. the log when pushing is as below

[DEBUG] running leetcode.submitProblem ⠋ Sending code to judge[TRACE] REQUEST %s { url: 'https://leetcode.com/problems/letter-combinations-of-a-phone-number/submit/', headers: { Cookie: , 'X-CSRFToken': , 'X-Requested-With': 'XMLHttpRequest', Origin: 'https://leetcode.com', Referer: 'https://leetcode.com/problems/letter-combinations-of-a-phone-number/description/' }, body: { judge_type: 'large', lang: 'cpp', question_id: 17, test_mode: false, typed_code: '..........................' }, method: 'POST', json: true, _delay: 1, callback: [Function] } [TRACE] REQUEST %s make request https://leetcode.com/problems/letter-combinations-of-a-phone-number/submit/ ⠏ Sending code to judge

Allenhua commented 6 years ago

[DEBUG] running leetcode.login [DEBUG] running leetcode.signin

zidoshare commented 6 years ago

需要在leetcode上注册账号,不是leetcode-cn。账号可以从leetcode同步到leetcode-cn中

skygragon commented 6 years ago

Thanks @zidoshare

@Allenhua are u using leetcode-cn account above? Seems leetcode.com and leetcode-cn.com hold different accounts thus your login always failed.

Allenhua commented 6 years ago

没有,我用的是 leetcode 的账户,我的一台机器上没有问题,另一台有问题。

dodouwang commented 6 years ago

This is a network problem caused by GFW of the mainland of China. After establishing a VPN connect, the issue is solved.

zidoshare commented 6 years ago

@dodouwang are you sure?it is 403. sorry,I can not get any more

GoingMyWay commented 6 years ago

尝试换个网络看看。我是通过换成手机热点的移动网络登录解决的。

NanayaHaruki commented 6 years ago

same problem. I can login, error appeared when I leetcode submit xxxxx

zidoshare commented 6 years ago

@Ayanokouji-Kenn please show the response code.

lianghowe commented 6 years ago

cn campus network cannot login.such as: Error: connect ECONNREFUSED 104.27.160.90:443 [0] you can use mobile hotspot . 就是校园网不一定能登录(), 用流量

NanayaHaruki commented 6 years ago

@zidoshare @skygragon leetcode-cn.com login successfully ,but can't submit.

>leetcode submit 1.two-sum.java
[ERROR] session expired, please login again [-1]
>leetcode user -l -vv
[TRACE] initializing all plugins
[TRACE] found plugin: cache=default
[TRACE] inited plugin: cache
[TRACE] found plugin: company=2017.12.18
[TRACE] inited plugin: company
[TRACE] found plugin: github=2018.03.24
[TRACE] inited plugin: github
[TRACE] found plugin: leetcode=default
[TRACE] inited plugin: leetcode
[TRACE] found plugin: retry=default
[TRACE] inited plugin: retry
[TRACE] found plugin: solution.discuss=2018.04.14
[TRACE] inited plugin: solution.discuss
[TRACE] missing plugins: 0
login: xuzhilin8818@163.com
pass:
[DEBUG] running leetcode.login
[DEBUG] running leetcode.signin
- Signing in leetcode.com[TRACE] REQUEST %s { uri: 'https://leetcode-cn.com/accounts/login/',
  callback: [Function] }
[TRACE] REQUEST %s make request https://leetcode-cn.com/accounts/login/
\ Signing in leetcode.com[TRACE] REQUEST %s onRequestResponse https://leetcode-cn.com/accounts/login/ 200 { server: 'nginx/1.10.3 (Ubuntu)',
  date: 'Thu, 21 Jun 2018 01:22:33 GMT',
  'content-type': 'text/html; charset=utf-8',
  'content-length': '19105',
  connection: 'close',
  vary: 'Accept-Encoding, Cookie',
  'x-frame-options': 'SAMEORIGIN',
  'set-cookie': <hidden>,
  'strict-transport-security': 'max-age=315360000; includeSubDomains' }
[TRACE] REQUEST %s reading response's body
[TRACE] REQUEST %s finish init function https://leetcode-cn.com/accounts/login/
[TRACE] REQUEST %s response end https://leetcode-cn.com/accounts/login/ 200 { server: 'nginx/1.10.3 (Ubuntu)',
  date: 'Thu, 21 Jun 2018 01:22:33 GMT',
  'content-type': 'text/html; charset=utf-8',
  'content-length': '19105',
  connection: 'close',
  vary: 'Accept-Encoding, Cookie',
  'x-frame-options': 'SAMEORIGIN',
  'set-cookie': <hidden>,
  'strict-transport-security': 'max-age=315360000; includeSubDomains' }
[TRACE] REQUEST %s end event https://leetcode-cn.com/accounts/login/
[TRACE] REQUEST %s has body https://leetcode-cn.com/accounts/login/ 19105
[TRACE] REQUEST %s emitting complete https://leetcode-cn.com/accounts/login/
[TRACE] REQUEST %s { url: 'https://leetcode-cn.com/accounts/login/',
  headers:
   { Origin: 'https://leetcode-cn.com',
     Referer: 'https://leetcode-cn.com/accounts/login/',
     Cookie: <hidden> },
  form:
   { csrfmiddlewaretoken: 'Iwc3jGfuvLLACoKN6ZsBYs3IV19VHoL8skoYfZfiLnFDXbQNJvh9uZ3xKb2b7Hll',
     login: '******',
     password: '******' },
  callback: [Function],
  method: 'POST' }
[TRACE] REQUEST %s make request https://leetcode-cn.com/accounts/login/
[TRACE] REQUEST %s onRequestResponse https://leetcode-cn.com/accounts/login/ 302 { server: 'nginx/1.10.3 (Ubuntu)',
  date: 'Thu, 21 Jun 2018 01:22:33 GMT',
  'content-type': 'text/html; charset=utf-8',
  'content-length': '0',
  connection: 'close',
  location: '/',
  'x-frame-options': 'SAMEORIGIN',
  vary: 'Cookie',
  'set-cookie':
   <hidden>]"; HttpOnly; Path=/; Secure',
     'csrftoken=uIZh6O2GQlpOHKqoGaUK2JghaJRo2ad3FNac0qcl8FxmwJ7NPFu8pFsf1rzitP0G; expires=Thu, 20-Jun-2019 01:22:33 GMT; Max-Age=31449600; Path=/; Secure',
     'LEETCODE_SESSION=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJfYXV0aF91c2VyX2lkIjoiNTEzNyIsIl9hdXRoX3VzZXJfYmFja2VuZCI6ImFsbGF1dGguYWNjb3VudC5hdXRoX2JhY2tlbmRzLkF1dGhlbnRpY2F0aW9uQmFja2VuZCIsIl9hdXRoX3VzZXJfaGFzaCI6IjdlNmMzZWZlMTg5OGY4ZDdmZWVhMGVlZGNkM2IwZTUyM2Q5ZTE4ZWMiLCJpZCI6NTEzNywiZW1haWwiOiJ4dXpoaWxpbjg4MThAMTYzLmNvbSIsInVzZXJuYW1lIjoiQXlhbm9rb3VqaS1LZW5uIiwidXNlcl9zbHVnIjoiYXlhbm9rb3VqaS1rZW5uIiwiYXZhdGFyIjoiaHR0cHM6Ly9hbGl5dW4tbGMtdXBsb2FkLm9zcy1jbi1oYW5nemhvdS5hbGl5dW5jcy5jb20vYWxpeXVuLWxjLXVwbG9hZC91c2Vycy9heWFub2tvdWppLWtlbm4vYXZhdGFyXzE1MjA0MDc5NTgucG5nIiwicGhvbmVfdmVyaWZpZWQiOmZhbHNlLCJ0aW1lc3RhbXAiOiIyMDE4LTA2LTIxIDAxOjIyOjMzLjQ2MjkwNiswMDowMCIsIlJFTU9URV9BRERSIjoiNDkuNzUuNjEuMTg0IiwiSURFTlRJVFkiOiIiLCJfc2Vzc2lvbl9leHBpcnkiOjB9.1gddP5PT1A1eZffrtoHN5Rl0xK-mpnGyqGrgns4ySlk; HttpOnly; Path=/; Secure' ],
  'strict-transport-security': 'max-age=315360000; includeSubDomains' }
[TRACE] REQUEST %s redirect /
[TRACE] REQUEST %s reading response's body
[TRACE] REQUEST %s finish init function https://leetcode-cn.com/accounts/login/
[TRACE] REQUEST %s response end https://leetcode-cn.com/accounts/login/ 302 { server: 'nginx/1.10.3 (Ubuntu)',
  date: 'Thu, 21 Jun 2018 01:22:33 GMT',
  'content-type': 'text/html; charset=utf-8',
  'content-length': '0',
  connection: 'close',
  location: '/',
  'x-frame-options': 'SAMEORIGIN',
  vary: 'Cookie',
  'set-cookie':
   <hidden>]"; HttpOnly; Path=/; Secure',
     'csrftoken=uIZh6O2GQlpOHKqoGaUK2JghaJRo2ad3FNac0qcl8FxmwJ7NPFu8pFsf1rzitP0G; expires=Thu, 20-Jun-2019 01:22:33 GMT; Max-Age=31449600; Path=/; Secure',
     'LEETCODE_SESSION=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJfYXV0aF91c2VyX2lkIjoiNTEzNyIsIl9hdXRoX3VzZXJfYmFja2VuZCI6ImFsbGF1dGguYWNjb3VudC5hdXRoX2JhY2tlbmRzLkF1dGhlbnRpY2F0aW9uQmFja2VuZCIsIl9hdXRoX3VzZXJfaGFzaCI6IjdlNmMzZWZlMTg5OGY4ZDdmZWVhMGVlZGNkM2IwZTUyM2Q5ZTE4ZWMiLCJpZCI6NTEzNywiZW1haWwiOiJ4dXpoaWxpbjg4MThAMTYzLmNvbSIsInVzZXJuYW1lIjoiQXlhbm9rb3VqaS1LZW5uIiwidXNlcl9zbHVnIjoiYXlhbm9rb3VqaS1rZW5uIiwiYXZhdGFyIjoiaHR0cHM6Ly9hbGl5dW4tbGMtdXBsb2FkLm9zcy1jbi1oYW5nemhvdS5hbGl5dW5jcy5jb20vYWxpeXVuLWxjLXVwbG9hZC91c2Vycy9heWFub2tvdWppLWtlbm4vYXZhdGFyXzE1MjA0MDc5NTgucG5nIiwicGhvbmVfdmVyaWZpZWQiOmZhbHNlLCJ0aW1lc3RhbXAiOiIyMDE4LTA2LTIxIDAxOjIyOjMzLjQ2MjkwNiswMDowMCIsIlJFTU9URV9BRERSIjoiNDkuNzUuNjEuMTg0IiwiSURFTlRJVFkiOiIiLCJfc2Vzc2lvbl9leHBpcnkiOjB9.1gddP5PT1A1eZffrtoHN5Rl0xK-mpnGyqGrgns4ySlk; HttpOnly; Path=/; Secure' ],
  'strict-transport-security': 'max-age=315360000; includeSubDomains' }
[TRACE] REQUEST %s end event https://leetcode-cn.com/accounts/login/
[TRACE] REQUEST %s emitting complete https://leetcode-cn.com/accounts/login/
[DEBUG] running leetcode.getFavorites
[TRACE] REQUEST %s { url: 'https://leetcode-cn.com/list/api/questions',
  headers:
   { Cookie: <hidden>,
     'X-CSRFToken': <hidden>,
     'X-Requested-With': 'XMLHttpRequest' },
  callback: [Function] }
[TRACE] REQUEST %s make request https://leetcode-cn.com/list/api/questions
[TRACE] REQUEST %s onRequestResponse https://leetcode-cn.com/list/api/questions 200 { server: 'nginx/1.10.3 (Ubuntu)',
  date: 'Thu, 21 Jun 2018 01:22:33 GMT',
  'content-type': 'application/json',
  'content-length': '366',
  connection: 'close',
  vary: 'Accept-Encoding, Cookie',
  allow: 'GET, POST, PUT, DELETE, HEAD, OPTIONS',
  'x-frame-options': 'SAMEORIGIN',
  'strict-transport-security': 'max-age=315360000; includeSubDomains' }
[TRACE] REQUEST %s reading response's body
[TRACE] REQUEST %s finish init function https://leetcode-cn.com/list/api/questions
[TRACE] REQUEST %s response end https://leetcode-cn.com/list/api/questions 200 { server: 'nginx/1.10.3 (Ubuntu)',
  date: 'Thu, 21 Jun 2018 01:22:33 GMT',
  'content-type': 'application/json',
  'content-length': '366',
  connection: 'close',
  vary: 'Accept-Encoding, Cookie',
  allow: 'GET, POST, PUT, DELETE, HEAD, OPTIONS',
  'x-frame-options': 'SAMEORIGIN',
  'strict-transport-security': 'max-age=315360000; includeSubDomains' }
[TRACE] REQUEST %s end event https://leetcode-cn.com/list/api/questions
[TRACE] REQUEST %s has body https://leetcode-cn.com/list/api/questions 366
[TRACE] REQUEST %s emitting complete https://leetcode-cn.com/list/api/questions
Successfully login as Ayanokouji-Kenn
jdneo commented 6 years ago

I have the same problem:

[TRACE] initializing all plugins
[TRACE] found plugin: cache=default
[TRACE] inited plugin: cache
[TRACE] found plugin: leetcode.cn=2018.05.30
[TRACE] inited plugin: leetcode.cn
[TRACE] found plugin: leetcode=default
[TRACE] inited plugin: leetcode
[TRACE] found plugin: retry=default
[TRACE] inited plugin: retry
[TRACE] missing plugins: 0
[DEBUG] cache hit: problems.json
[DEBUG] cache hit: 1.two-sum.algorithms.json
[DEBUG] running leetcode.submitProblem
- Sending code to judge[TRACE] REQUEST %s { url: 'https://leetcode-cn.com/problems/two-sum/submit/',
  headers:
   { Cookie: <hidden>,
     'X-CSRFToken': <hidden>,
     'X-Requested-With': 'XMLHttpRequest',
     Origin: 'https://leetcode-cn.com',
     Referer: 'https://leetcode.com/problems/two-sum/description/' },
  body:
   { judge_type: 'large',
     lang: 'java',
     question_id: 1,
     test_mode: false,
     typed_code: '/*\n * [1] Two Sum\n *\n * https://leetcode.com/problems/two-sum/description/\n *\n * algorithms\n * Easy (38.64%)\n * Total Accepted:    1M\n * Total Submissions: 2.6M\n * Testcase Example:  \'[2,7,11,15]\\n9\'\n *\n * Given an array of integers, return indices of the two numbers such that they\n * add up to a specific target.\n * \n * You may assume that each input would have exactly one solution, and you may\n * not use the same element twice.\n * \n * Example:\n * \n * \n * Given nums = [2, 7, 11, 15], target = 9,\n * \n * Because nums[0] + nums[1] = 2 + 7 = 9,\n * return [0, 1].\n * \n * \n * \n * \n */\nclass Solution {\n    public int[] twoSum(int[] nums, int target) {\n        return null;\n    }\n}\n' },
  method: 'POST',
  json: true,
  _delay: 1,
  callback: [Function] }
[TRACE] REQUEST %s make request https://leetcode-cn.com/problems/two-sum/submit/
- Sending code to judge[TRACE] REQUEST %s onRequestResponse https://leetcode-cn.com/problems/two-sum/submit/ 403 { server: 'nginx/1.10.3 (Ubuntu)',
  date: 'Tue, 14 Aug 2018 09:48:18 GMT',
  'content-type': 'text/html; charset=utf-8',
  'content-length': '5867',
  connection: 'close',
  vary: 'Accept-Encoding, Cookie',
  'content-security-policy': 'frame-ancestors \'self\' https://*.leetcode.com https://leetcode.com https://*.leetcode-cn.com https://leetcode-cn.com https://*.lingkou.com https://lingkou.com https://tongji.baidu.com https://www.growingio.com',
  'x-frame-options': 'SAMEORIGIN',
  'strict-transport-security': 'max-age=315360000; includeSubDomains' }
[TRACE] REQUEST %s reading response's body
[TRACE] REQUEST %s finish init function https://leetcode-cn.com/problems/two-sum/submit/
[TRACE] REQUEST %s response end https://leetcode-cn.com/problems/two-sum/submit/ 403 { server: 'nginx/1.10.3 (Ubuntu)',
  date: 'Tue, 14 Aug 2018 09:48:18 GMT',
  'content-type': 'text/html; charset=utf-8',
  'content-length': '5867',
  connection: 'close',
  vary: 'Accept-Encoding, Cookie',
  'content-security-policy': 'frame-ancestors \'self\' https://*.leetcode.com https://leetcode.com https://*.leetcode-cn.com https://leetcode-cn.com https://*.lingkou.com https://lingkou.com https://tongji.baidu.com https://www.growingio.com',
  'x-frame-options': 'SAMEORIGIN',
  'strict-transport-security': 'max-age=315360000; includeSubDomains' }
[TRACE] REQUEST %s end event https://leetcode-cn.com/problems/two-sum/submit/
[TRACE] REQUEST %s has body https://leetcode-cn.com/problems/two-sum/submit/ 5867
[TRACE] REQUEST %s invalid JSON received https://leetcode-cn.com/problems/two-sum/submit/
[TRACE] REQUEST %s emitting complete https://leetcode-cn.com/problems/two-sum/submit/
[DEBUG] http error: 403
[ERROR] session expired, please login again [-1]
freephys commented 6 years ago

在美国也出错 401. 这个问题困扰这个工具的最大优势 [DEBUG] running cookie.chrome.login [DEBUG] running cookie.chrome.signin [DEBUG] try to copy leetcode cookies from chrome ... [DEBUG] Successfully copied leetcode cookies! [DEBUG] running leetcode.getFavorites [TRACE] REQUEST %s { url: 'https://leetcode.com/list/api/questions', headers: { Cookie:

, 'X-CSRFToken': , 'X-Requested-With': 'XMLHttpRequest' }, callback: [Function] } [TRACE] REQUEST %s make request https://leetcode.com/list/api/questions [TRACE] REQUEST %s onRequestResponse https://leetcode.com/list/api/questions 401 { date: 'Mon, 20 Aug 2018 03:04:21 GMT', 'content-type': 'application/json', 'content-length': '58', connection: 'close', 'set-cookie': , 'www-authenticate': 'Bearer realm="api"', allow: 'GET, POST, PUT, DELETE, HEAD, OPTIONS', 'x-frame-options': 'SAMEORIGIN', vary: 'Cookie', 'strict-transport-security': 'max-age=31536000; includeSubDomains; preload', 'x-content-type-options': 'nosniff', 'expect-ct': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"', server: 'cloudflare', 'cf-ray': '44d1a1cf6ade8327-ATL' } [TRACE] REQUEST %s reading response's body [TRACE] REQUEST %s finish init function https://leetcode.com/list/api/questions [TRACE] REQUEST %s response end https://leetcode.com/list/api/questions 401 { date: 'Mon, 20 Aug 2018 03:04:21 GMT', 'content-type': 'application/json', 'content-length': '58', connection: 'close', 'set-cookie': , 'www-authenticate': 'Bearer realm="api"', allow: 'GET, POST, PUT, DELETE, HEAD, OPTIONS', 'x-frame-options': 'SAMEORIGIN', vary: 'Cookie', 'strict-transport-security': 'max-age=31536000; includeSubDomains; preload', 'x-content-type-options': 'nosniff', 'expect-ct': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"', server: 'cloudflare', 'cf-ray': '44d1a1cf6ade8327-ATL' } [TRACE] REQUEST %s end event https://leetcode.com/list/api/questions [TRACE] REQUEST %s has body https://leetcode.com/list/api/questions 58 [TRACE] REQUEST %s emitting complete https://leetcode.com/list/api/questions [DEBUG] http error: 401 [ERROR] session expired, please login again [-1]
SonglinYu1230 commented 5 years ago

@Allenhua leetcode plugin -D leetcode.cn 我用的leetcode.com的账号,期初也登录不上去,用上面的命令把leetcode.cn插件删掉就可以登录了。

skygragon commented 5 years ago

@yumumu 刚更新了一下,现在leetcode/lintcode/leetcode.cn插件使用独立的目录来保存数据,应该不会有这种数据冲突的问题了

https://github.com/skygragon/leetcode-cli/commit/b72d4d69fe6b3279d3f40f00bb836696139a2fcc https://github.com/skygragon/leetcode-cli-plugins/commit/5ef609e75e3f19451d83ccd61e70b669d972e640

zYeoman commented 4 years ago

Sorry, it's because of lintcode plugin.....All work well after I disable that plugin.

Can login, but can't get a session.

mickir@matrixlib [19:57:56] [~/src/leetcode] [master]
-> % leetcode user -l -v
login: zhuangyw.thu@gmail.com
pass:
[DEBUG] running lintcode.login
Successfully login as zhuangyw.thu@gmail.com
Time: 0h:00m:08s
mickir@matrixlib [19:58:16] [~/src/leetcode] [master]
-> % leetcode session
[ERROR] session expired, please login again [code=-1]
Kyuseilee commented 4 years ago

不能同时登录网页和插件吗?我以前可以的啊今天登插件掉网页登网页掉插件。。。。

huanzhang commented 3 years ago

看看是不是邮箱未验证,我的验证下就解决了

javanli commented 9 months ago

有的是Cloudflare拦截了,尽量避免频繁切换设备和代理节点