Python Forum
Requests needs cookies for login
Thread Rating:
  • 3 Vote(s) - 3.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Requests needs cookies for login
#1
I am trying to login into my email account through a website and run an action when I get a new email (I can't use IMAP, because it's a paid feature). I use the Requests module.

I looked at the POST request Firefox made when logging in and copied the data. When I submit it and look at the response's content, it says "To access your mail.com mailbox you must enable cookies in your browser."

Can someone tell me what I am doing wrong? I checked the cookies for the Session object and it has cookies.

Here's what I have. Feel free to use the testing account information to login and inspect the POST request in your web browser and test it with Python yourself. Note: check the comments, I had to remove the https:// parts of the address out, because it doesn't let me to post "clickable links" yet, not even in code tags.
 
import requests

user = "[email protected]"
psswd = "fortesting"
# had to leave out the https part because it doesn't allow me to post "clickable links"
website = "www.mail.com"
# same for this as above
POST_url = "login.mail.com/login#.1258-header-login1-2"

# from the POST request info from Firefox's developer tools
params = {
    "service": "mailint",
    "uasServiceID": "mc_starter_mailcom",
    # same as above, had to leave https:// out for the successURL, loginFailedURL and loginErrorURL
    "successURL": "$(clientName)-$(dataCenter).mail.com/login",
    "loginFailedURL": "www.mail.com/int/logout/?ls=wd",
    "loginErrorURL": "www.mail.com/int/logout/?ls=te",
    "edition": "int",
    "lang": "en",
    "usertype": "standard",
    "username": user,
    "password": psswd
}

sess = requests.Session()
response = sess.post(POST_url, data=params)
print(response.text)
Reply


Messages In This Thread
Requests needs cookies for login - by justasug - Jul-26-2017, 08:30 AM
RE: Requests needs cookies for login - by nilamo - Jul-26-2017, 04:23 PM
RE: Requests needs cookies for login - by justasug - Jul-27-2017, 08:38 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to accept facebook cookies using python selenium? pablo86ad 0 281 Apr-06-2024, 09:19 PM
Last Post: pablo86ad
  in a login interface when i try login with a user supposed to say test123 but nothing NullAdmin 3 2,344 Feb-20-2021, 04:43 AM
Last Post: bowlofred
  Retrieving Cookies whois1230 2 2,232 Nov-21-2020, 12:01 PM
Last Post: snippsat
  Cookies Donald 3 2,885 Apr-15-2020, 07:06 AM
Last Post: DPaul

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020