Why do I get 401 Status code from post request?

偶尔善良 提交于 2019-12-13 03:47:10

问题


I am trying to login to a website using python requests library, but keep getting a 401 status code.

I have tried many variations of the various post function variables including:

  • data = formData, form data includes the correct username, password and _csrf token

  • data = json.dumps(formData)

  • headers = headers (which included the "user-agent" and many other fields)

  • auth = HTTPBasicAuth(username,password) where username and password are the correct string variables for the site login

with requests.Session() as c:
    loginPage = c.get(LoginURL)
    loggedInPage = c.post(LoginURL, 
                          data=formData,
                          headers=headers,
                          auth=HTTPBasicAuth(username,password)
                    )

来源:https://stackoverflow.com/questions/57092286/why-do-i-get-401-status-code-from-post-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!