-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
scrapy authentication login with cookies not working as expected #5597
Comments
I thought maybe you were passing cookies through a header because of the Please, refactor your report to make your example minimal. |
@Gallaecio , I just refactored my code. How can I resolve the issue of getting logged out after I am authenticated by a site? |
Your example is still not minimal. Remove any code that is not required to reproduce the issue. |
@Gallaecio I feel this has got to do with scrapy because I have checked similar questions on SO and no solution was provided. |
@Gallaecio Please I need help authenticating user sessions using scrapy. |
The provided log shows that the login page wasn't even requested successfully (it's broken but I doubt the missing part contains getting a successful response). And even if the original code works (we can't test the provided one because that would need an account), it doesn't actually check that the logging in works, only that "Wrong username or password" isn't returned.
Such as?
It's a builtin feature, used by others successfully. |
Hi @wRAR, I just update the question with all logs, as you can see on the log, I successfully logged in. Here is a dummy account details for you to test with. username = password = `A151515a |
http://oddsportal.com/results/ behaves the same in the browser without JS: it doesn't show you are logged in. This is not a bug. |
@wRAR It does not behave the same way in the browser, It shows that I am logged in. Try and sign in with the above details and navigate to the above link you said it behaves the same way. Selenium maintains a user session after log-in, why does scrapy log out when a new request is spawned after log-in? I have compared my browser cookies and that of scrapy and I can find any difference, why then are my logged out. |
It does not show that when JS is disabled.
You are yet to prove that Scrapy "logs out". I believe that it doesn't. When you have the minimal reproducible example of this claim about Scrapy, you can provide it. Until that, this will stay closed as not a Scrapy bug. And if you still think it's a Scrapy bug, you can try to reproduce this on a different, simpler website. |
Hi @wRAR, Here is a minimal example from both selenium and scrapy with their response after login. Selenium Example.
Scrapy Example
As proof that I logged in, I tried logging in with the wrong username which resulted to But when I switch my request to https://www.oddsportal.com/settings/ after log-in I get this. |
You've again missed my point about disabling JS. If you worry about the "Login" link, disable JS when looking at the page opened by |
I just examined the response generated from my request using |
Sure, Splash doesn't reuse Scrapy cookies. This is my last comment here until I see any actual reproducible Scrapy problem. |
You seem to have experimented with scrapy-playwright as well (scrapy-plugins/scrapy-playwright#110), why did you scratch that approach? |
Description
sending a request to a page after log-in does not seem to maintain the user session. I am able to log in, but when I send a request to another page on the same site, The response from this page shows that I am logged out. I am able to do this seamlessly using selenium but replicating the same result in scrapy has been a hard nut to crack. Currently, I have tried out three different methods.
Using Scrapy to get cookies from a request and passing that to the next request.
Using selenium driver to get cookies from a request and passing the cookie to the next scrapy request.
Using the Builtin method in scrapy cookiejar
With Scrapy
Steps to Reproduce
Expected behavior:
Code.
I expect the response to another page within the site to maintain the user session, but it shows that I am logged out.
Reproduces how often: [What percentage of the time does it reproduce?]
Scrapy Versions 2.6.2
The text was updated successfully, but these errors were encountered: