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

Use cookie instead of credentials for authentication #41

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

LBBO
Copy link
Owner

@LBBO LBBO commented Feb 17, 2021

This PR changes the authorization method from credentials to cookies. This means the user will have to login manually and then extract the cookies set in their browser by Netflix. Sadly, this is now necessary, as Netflix added reCAPTCHA to their login form, as described in #37.

Fixes #37; corresponds to LBBO/netflix-migrate#54

@jowie
Copy link

jowie commented Feb 28, 2021

Hi, does this fix the issue found in #20 ?

@LBBO
Copy link
Owner Author

LBBO commented Feb 28, 2021

Hey @jowie. Not really. #20 has been fixed since #29 (I just forgot to close it). You are kind of right, however, in that this PR makes the issue obsolete as a normal login no longer exists. The current error message still needs to be updated to reflect the new authorization method (which will happen before this PR is merged) but that isn't really related to #20.

@LBBO
Copy link
Owner Author

LBBO commented Feb 28, 2021

@jowie I forgot to mention that a similar error still occurs for some users when they use the current version with username and password login, due to Netflix' new use of reCAPTCHA. In that case, the issue isn't incorrect credentials but just reCAPTCHA doing its job. This PR does fix that issue. For a more detailed discussion about that topic, please take a look at LBBO/netflix-migrate#37.

@jowie
Copy link

jowie commented Mar 1, 2021

@LBBO thank you for the helpful info! I used the release version yesterday and managed to export my old profile JSON, but unfortunately was unable to import it into my new account due to the error. I'd love to give this branch a go, but I'm afraid I don't know how to run JS in the terminal (on a Mac)... Could you point me to some advice as to how to install and run this code? And Also if you have any information on how to retrieve a cookie from a browser such as Chrome or Safari? (although I'm sure I could look that last bit up if necessary)

I appreciate this is not your responsibility but I'm just very keen to try and migrate my old profile now I am not piggybacking off my parent's Netflix account 😉 thank you!

  • UPDATE - I've managed to export my cookies and there appear to be a few (nfvdid, SecureNetflixId, NetflixId, memclid) - I'm assuming it's NetflixId which is the long one?

@LBBO
Copy link
Owner Author

LBBO commented Mar 1, 2021

Hey @jowie,

it sounds like you want to just migrate your account data and that is precicely what netflix-migrate is there for. This repository just provides the JS library netflix-migrate is built upon so that others can build their own software using Netflix' services. If I am correct and you just want to migrate, this discussion should probably take place over there.

To answer your question, though: I have written an explenation on how to use the new netflix-migrate version in the updated README you can find here. As for the cookies: Those should all just be one single string, such as

memclid=[...]; hasSeenCookieDisclosure=true; dsca=anonymous; nfvdid=[...]; pas=[...]; OptanonConsent=isIABGlobal=false&datestamp=[...]&version=[...]&consentId=[...]&interactionCount=1&landingPath=NotLandingPage&groups=[...]&hosts=[...]&AwaitingReconsent=false; lhpuuidh-browse-[...]=[...]; lhpuuidh-browse-[...]-T=[...]; clSharedContext=[...]; SecureNetflixId=[...]; NetflixId=[...]; playerPerfMetrics=[...]; profilesNewSession=0

If you use Chrome, it is important that you manually select the entire string as explained in the README and copy it using Cmd + C instead of just right-clicking the value and selecting "Copy value", as that actually decodes the cookie before copying it.

Everything else should be explained well enough in the README. Please let me know if you run into any more problems.

@jowie
Copy link

jowie commented Mar 2, 2021

Hi @LBBO - thanks for your reply!

Sorry I'm off-topic here... I followed a link in an issue over there and didn't realise I was chatting in the wrong repo! Thanks for the advice... I will give it a go today and if I have any problems I will message you directly or over on the correct repo.

Thanks again!

@CHarnel
Copy link

CHarnel commented Mar 11, 2021

Hi @LBBO,
When do you think this PR will be merged?

@LBBO
Copy link
Owner Author

LBBO commented Mar 11, 2021

Hey @CHarnel, it'll be merged once enough users report that it works for them. There are also a few minor adjustments I want to make before then, but they should be quick. Also, nothing is going to happen in the next week as I have an exam coming up.

@quophyie
Copy link

quophyie commented May 8, 2021

@LBBO ... I have tried this new beta version i..e 2.0.0-beta.3 and it does not work for me. I keep getting the error below when I call the login method with the cookie

Error: Inactive account

My account is not inactive because its brand new account and I can watch netflix with it. In fact, I have another active account and I get the same error when I use the cookie from that account to try and login as well

Any ideas?

here is the full stacktrace

Error: Inactive account
    at Netflix.__getContextData (/Users/gigi/u01/projects/node-migrate-tests/node_modules/netflix2/lib/netflix2.js:555:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Netflix.__getContextDataFromUrls (/Users/gigi/u01/projects/node-migrate-tests/node_modules/netflix2/lib/netflix2.js:594:7)
    at async Netflix.login (/Users/gigi/u01/projects/node-migrate-tests/node_modules/netflix2/lib/netflix2.js:76:9)
The exact response HTML file was saved to /Users/gigi/u01/projects/node-migrate-tests/errorResponsePage.html
Error: There was a problem fetching user data. For more information, see previous log statements.
    at Netflix.__getContextData (/Users/gigi/u01/projects/node-migrate-tests/node_modules/netflix2/lib/netflix2.js:584:13)
    at async Netflix.__getContextDataFromUrls (/Users/gigi/u01/projects/node-migrate-tests/node_modules/netflix2/lib/netflix2.js:594:7)
    at async Netflix.login (/Users/gigi/u01/projects/node-migrate-tests/node_modules/netflix2/lib/netflix2.js:76:9)

here is the code that I'm using to test

var Netflix = require("netflix2")
var cookies = "my-really-long-cookie"
cookies = cookies.split(/\r?\n/gm).join('').trim()
var credentials = {cookies}

netflix = new Netflix()
netflix.login(credentials)
    .then(() => console.log("logged in succesfully"))
.catch(() => console.log("logged in FAILED"))

@itskush
Copy link

itskush commented May 29, 2021

@LBBO ... I have tried this new beta version i..e 2.0.0-beta.3 and it does not work for me. I keep getting the error below when I call the login method with the cookie

Error: Inactive account

My account is not inactive because its brand new account and I can watch netflix with it. In fact, I have another active account and I get the same error when I use the cookie from that account to try and login as well

Any ideas?

here is the full stacktrace

Error: Inactive account
    at Netflix.__getContextData (/Users/gigi/u01/projects/node-migrate-tests/node_modules/netflix2/lib/netflix2.js:555:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Netflix.__getContextDataFromUrls (/Users/gigi/u01/projects/node-migrate-tests/node_modules/netflix2/lib/netflix2.js:594:7)
    at async Netflix.login (/Users/gigi/u01/projects/node-migrate-tests/node_modules/netflix2/lib/netflix2.js:76:9)
The exact response HTML file was saved to /Users/gigi/u01/projects/node-migrate-tests/errorResponsePage.html
Error: There was a problem fetching user data. For more information, see previous log statements.
    at Netflix.__getContextData (/Users/gigi/u01/projects/node-migrate-tests/node_modules/netflix2/lib/netflix2.js:584:13)
    at async Netflix.__getContextDataFromUrls (/Users/gigi/u01/projects/node-migrate-tests/node_modules/netflix2/lib/netflix2.js:594:7)
    at async Netflix.login (/Users/gigi/u01/projects/node-migrate-tests/node_modules/netflix2/lib/netflix2.js:76:9)

here is the code that I'm using to test

var Netflix = require("netflix2")
var cookies = "my-really-long-cookie"
cookies = cookies.split(/\r?\n/gm).join('').trim()
var credentials = {cookies}

netflix = new Netflix()
netflix.login(credentials)
    .then(() => console.log("logged in succesfully"))
.catch(() => console.log("logged in FAILED"))

Hey having the same issue here. Did you manage to find a fix for it?

@quophyie
Copy link

quophyie commented Jun 1, 2021

@itskush ... I havent managed to find a solution yet

@StevieApp
Copy link

I'm trying to use the cookie from my account on netflix2 and email and password on netflix-migrate and I'm receiving the same issue Cannot read property 'data' of undefined

@sonkkeli
Copy link

sonkkeli commented Feb 28, 2022

I got it working, but instead of using the document.cookie I was spying the cookies from the request sent to the API (you can see this in dev console under network). I guess there are some "secret cookies" that didnt get printed with document.cookie.

So I debug printed the URL and visited e.g. https://www.netflix.com/api/shakti/v74c04a5c/profiles (you need to debug print to get the current version of the api). And then checked the cookies from Network tab sent with the request.

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

Successfully merging this pull request may close these issues.

reCAPTCHA on Netflix login page causing authentication failures
7 participants