kawre / leetcode.nvim

A Neovim plugin enabling you to solve LeetCode problems.
MIT License
1.05k stars 45 forks source link

Chrome's tokens don't work, you need to use Firefox. Made that clear in the README. #53

Closed ArjunSahlot closed 7 months ago

kawre commented 8 months ago

You mean the cookie? I just checked and they are indeed different, but logging in still works.

Can you post your cookie without the values, so I know how the format looks?

ArjunSahlot commented 8 months ago

Yup the cookie. Here's my cookie on Chrome:

csrftoken=[VALUE];
messages=[VALUE];
__stripe_mid=[VALUE];
LEETCODE_SESSION=[VALUE];
_ga=[VALUE];
_gid=[VALUE];
_dd_s=[VALUE];
_ga_CDRWKZTDEX=[VALUE]

Compared to Firefox:

csrftoken=[VALUE];
_ga_[VALUE?]=[VALUE];
_ga=[VALUE];
_dd_s=rum=[VALUE];
_gid=[VALUE];
gr_user_id=[VALUE];
[VALUE?]_gr_session_id=[VALUE];
[VALUE?]_gr_session_id_sent_vst=[VALUE];
LEETCODE_SESSION=[VALUE];
messages=[VALUE];
[VALUE?]_gr_last_sent_sid_with_cs1=[VALUE];
[VALUE?]_gr_last_sent_cs1=[VALUE};
[VALUE?]_gr_cs1=[VALUE]

I removed some characters I thought might hold data (marked as [VALUE?]) and removed some that I was sure were data (marked as [VALUE]). Don't want my info floating around online lmao.

kawre commented 8 months ago

Cookie parser looks only for csrftoken and LEETCODE_SESSION tokens, which both are present in both cookies. What error do you get when pasting the cookie from chrome?

    local csrf = str:match("csrftoken=([^;]+)")
    if not csrf or csrf == "" then return nil, "Bad csrf token format" end

    local ls = str:match("LEETCODE_SESSION=([^;]+)")
    if not ls or ls == "" then return nil, "Bad leetcode session token format" end
ArjunSahlot commented 7 months ago

Cookie parser looks only for csrftoken and LEETCODE_SESSION tokens, which both are present in both cookies. What error do you get when pasting the cookie from chrome?

    local csrf = str:match("csrftoken=([^;]+)")
    if not csrf or csrf == "" then return nil, "Bad csrf token format" end

    local ls = str:match("LEETCODE_SESSION=([^;]+)")
    if not ls or ls == "" then return nil, "Bad leetcode session token format" end

Whoops didn't get this notification. I got the Bad csrf token format error.

kawre commented 7 months ago

That shouldn't happen since looking at the formats you've sent, chrome cookies contains csrftoken. Are you sure it's not an error on your end?