Unable to log in to website using POST request
P粉087951442
P粉087951442 2023-09-08 12:18:17
0
1
353

I tried to log in using a POST request from python https://admin.raptor.software but was unable to log in.

I'm using the following code snippet:

import requests_html

session = requests_html.HTMLSession()

r = session.get('https://admin.raptor.software')
csrf = r.html.xpath('/html/head/meta[4]')[0].attrs['content']

data = {
    'client_id': '2',
    'client_secret': csrf,
    'grant_type': 'password',
    'password': 'MYPASSWORD',
    'username': 'MYEMAIL'
}
session.post('https://admin.raptor.software/api/login', data = data)

I need it to publish csrf, so I use the requests_html library to get it.

After successful login, I want to print the dashboard HTML using the following code, but it posts the login page HTML above:

r = session.get('https://admin.raptor.software/dashboard')
print(r.text)
<!doctype html>
<html lang="de">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1,user-scalable=0">
        <meta name="csrf-token" content="eFC7HQfM9NJdi8u1nxQjDubUNjLLjVrmVmM1T4mD">
        <link href="/css/app.css?id=39d4a60bbe483994f0ec" rel="stylesheet">
        <title>Admin</title>

        <!-- Fonts -->
        <link rel="dns-prefetch" href="//fonts.gstatic.com">
        <link rel="preconnect" href="https://fonts.gstatic.com">
        <link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">

        <!-- Styles -->
        <link href="https://admin.raptor.software/css/app.css" rel="stylesheet">
        <link href="https://admin.raptor.software/css/modules.css" rel="stylesheet">
        <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
    </head>
    <body>
        <div id="app">
            
        </div>
        
        <script src="/js/app.js?id=3f08b75b370e0e33ea8b"></script>
        <script src="/js/modules.js?id=65903b83a0bc6fc9f233"></script>
    </body>
</html>

P粉087951442
P粉087951442

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!