1

I want to use Python's requests module to login to the webpage https://www.tennistv.com/login.

I read this post on how to achieve this, however, I get stuck. The payload looks as follows:

payload = {"Email":"[MAIL]","Password":"[PASSWORD]"}

I then start a session as follows:

with requests.Session() as s:
    p = s.post('https://www.tennistv.com/api/users/v1/login', data=payload, headers=headers)
    # print the html returned or something more intelligent to see if it's a successful login page.
    print(p.text)

This yields the following error:

{
    "error": {
        "validationErrors": [{
            "key": "loginModel",
            "value": [""]
        }],
        "errorMessage": "There was an error while validating input data (UR001)",
        "errorCode": "UR001",
        "userErrorCode": "UR001"
    }
}

Even when I copy the request from Chrome's developer console as a cURL command and then execute the cURL command, I get the same error.

The cURL command looks as follows:

curl "https://www.tennistv.com/api/users/v1/login" -H "Pragma: no-cache" -H "Origin: https://www.tennistv.com" -H "Accept-Encoding: gzip, deflate, br" -H "Accept-Language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36" -H "content-type: application/json" -H "Accept: */*" -H "Cache-Control: no-cache" -H "Referer: https://www.tennistv.com/login" -H "Connection: keep-alive" --data-binary "^{^\^"Email^\^":^\^"[MAIL]^\^",^\^"Password^\^":^\^"[PASS]^\^"^}" --compressed

What am I doing wrong? Where is the difference between the cURL command and the request sent by the browser?

beta
  • 5,324
  • 15
  • 57
  • 99
  • Have you tried faking the user agent? – Ulrich Eckhardt Mar 11 '18 at 21:16
  • yes. i tried with: `'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36'` – beta Mar 11 '18 at 21:39
  • In any case, you already mentioned how you can reduce the problem further, by only using the working Chrome (working) and cURL (not working). It would be useful if you reduced your question to that and mentioned the exact cURL commandline (excluding credentials, of course). – Ulrich Eckhardt Mar 11 '18 at 21:43
  • the cURL is this: https://pastebin.com/U1xdHdsH can you detect any difference to the request sent by the browser? – beta Mar 12 '18 at 07:26
  • Doesn't work like that. Edit your question so that it is focused on the issue and all necessary information is contained. In order to understand the issue, it shouldn't be necessary to read the comments. – Ulrich Eckhardt Mar 12 '18 at 19:09

1 Answers1

1

I could resolve this issue. The payload has to look as follows (different quotation marks):

payload = {'Email':'[MAIL]','Password':'[PASSWORD]'}
beta
  • 5,324
  • 15
  • 57
  • 99