Home > Mobile >  Hidden Form Headers while inspecting page?
Hidden Form Headers while inspecting page?

Time:02-01

I was trying to log into roll20.com using requests but I wasn't able to find the Form Headers with the login info in the DevTools while inspecting the webpage. Is it possible that those are hidden to prevent people like me from doing what I'm trying to do?

CodePudding user response:

After some research I can conclude, that you can login via requests using code below (at least it works on roll20.net):

import requests
import base64
import re

loginData = {
    'email':'[email protected]',
    'password':'password'}

# basic headers for request
headers = {
    'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:96.0) Gecko/20100101 Firefox/96.0',
    'Accept': 'application/json, text/plain, */*',
    'Referer':'https://app.roll20.net/login'}

# send request for creating a session
resp1 = requests.post(
    url='https://app.roll20.net/v2/sessions/create', 
    data=loginData,
    headers=headers)


# parse cookie from response header
# we need it to authorizate successfully
cookie = resp1.headers['set-cookie']
cookie = re.search(r'(rack.session=([^;] ))', cookie).group()
headers['Cookie'] = cookie

print(resp1.status_code)
print(resp1.headers)
print('\n\n')

# update header 'Referer'
headers['Referer']='https://app.roll20.net/login'

# requesting home page of the site
resp2 = requests.get(
    url='https://app.roll20.net/home', 
    headers=headers)

print(resp2.status_code)
print(resp1.headers)
print('\n\n\n')

# saving last response body as file to check it was ok
with open('index.html', 'w', encoding='utf-8') as file:
        file.writelines(resp2.text)

All you need - provide your own login/password in loginData dictionary. After that you can check file index.html, there you can find authorization was successful.

Final result in index.html

Can't find any useful of this anyway, it's up to you.

  •  Tags:  
  • Related