:http:// localhost/admin/login/?next=o/authorize/%3Fresponse_type%3Dcode_crethall326
我希望在<代码>http:// localhost/questback?code=xxx上登机。
法典:
import os
import requests
from urllib.parse import urlparse, parse_qs
url = "http://localhost/admin/"
auth_url = http://localhost/o/authorize/?response_type=code&code_challenge=xxx&code_challenge_method=S256&client_id=xxx&redirect_uri=http://localhost/callback
email = "email"
password = "password"
session = requests.Session()
session.get(url)
login_payload = {
email : email,
password : password,
csrfmiddlewaretoken : session.cookies[ csrftoken ]
}
login_req = session.post(url, data=login_payload)
print(login_req)
print(login_req.url)
auth_page = session.get(auth_url)
print(auth_page)
print(auth_page.url)
output:
<Response [200]>
http://localhost/admin/login/?next=/admin/
<Response [200]>
http://localhost/admin/login/?next=/o/authorize/%3Fresponse_type%3Dcode%26code_challenge%3Dxxx%26code_challenge_method%3DS256%26client_id%3Dxxx%26redirect_uri%3Dhttp%3A//localhost/callback
能够拿回的圆顶,如<条码>http:// localhost/questback?code=xxx。