使用python自动获取授权头承载

2024-09-21 05:38:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我想用python获取头身份验证承载器。我已经运行了下面的代码,但是我有一个空返回(Response[500],Response[200])

你能给我一些指导方针来找出问题并找到解决方案吗

1.

import requests

headers = {
    'authority': 'desk-api.nomination.fr',
    'pragma': 'no-cache',
    'cache-control': 'no-cache',
    'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="90", "Google Chrome";v="90"',
    'accept': 'application/json, text/plain, */*',
    'sec-ch-ua-mobile': '?0',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36',
    'content-type': 'application/json;charset=UTF-8',
    'origin': 'https://app.nomination.fr',
    'sec-fetch-site': 'same-site',
    'sec-fetch-mode': 'cors',
    'sec-fetch-dest': 'empty',
    'referer': 'https://app.nomination.fr/',
    'accept-language': 'en-US,en;q=0.9',
}

data = '{"login":"xxxxx","password":""}'

response = requests.post('https://desk-api.nomination.fr/v1/authentication/auth/local', headers=headers, data=data)

2.

import requests
username ="xxxx",
password = "ppp",
url = "https://app.xxxx.fr/login?fromState=app.home/"
with requests.session() as session:
    reponse  = session.post(url, auth = (username,password))

Tags: httpsimportappcachedataresponsesessionpassword

热门问题