WinHTTPRequest status 403

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Loop
Posts: 169
Joined: 07 Jan 2019, 14:51

WinHTTPRequest status 403

Post by Loop » 17 Sep 2020, 12:59

Hi,
If WinHTTPRequest status is 403, it means that it is not possible, because it is unwanted via WinHTTPRequest?
Or I do something wrong?
What does 403 mean?


MyCode:

Code: Select all

oHTTP := ComObjCreate("WinHttp.WinHttpRequest.5.1")
oHTTP.Open("GET", "https://www.foo.com", True)
oHTTP.SetRequestHeader("Referer" , "https://www.foobar.com/login")
oHTTP.SetRequestHeader("Connection" , "keep-alive")

oHTTP.Send()
oHTTP.WaitForResponse()
respo := oHTTP.ResponseText()

tokennr := "<input type=""hidden"" name=""CSRFToken"" value=""(.*?)"" />"
RegExMatch(Respo, tokennr, Token)

PostData := "username=12345678&password=98765431&CSRFToken=" Token1

oHTTP.Open("POST", "https://www.foo.com/security_check")
oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0")
oHTTP.SetRequestHeader("Accept" , "text/html,application/xhtml+xml,application/xml")
oHTTP.SetRequestHeader("Accept-Language" , "en")
oHTTP.SetRequestHeader("Content-Type" , "application/x-www-form-urlencoded")
oHTTP.SetRequestHeader("Upgrade-Insecure-Requests" , "1")
oHTTP.SetRequestHeader("Accept-Encoding" , "gzip")
oHTTP.SetRequestHeader("Content-Length" , "95")
oHTTP.SetRequestHeader("TE" , "Trailers")
oHTTP.SetRequestHeader("Pragma", "no-cache")
oHTTP.SetRequestHeader("Cache-Control", "no-cache, no-store")
oHTTP.SetRequestHeader("Referer", "https://www.foo.comlogin")
oHTTP.SetRequestHeader("Connection" , "keep-alive")
oHTTP.Send(PostData)
oHTTP.WaitForResponse()
MsgBox, % oHTTP.status

Thanks


romankris
Posts: 1
Joined: 15 Aug 2022, 00:50

Re: WinHTTPRequest status 403

Post by romankris » 15 Aug 2022, 00:53

Loop wrote:
17 Sep 2020, 12:59
What does 403 mean?
This error indicates that the server has determined that you are not allowed access to the thing you've requested, either on purpose or due to a misconfiguration . It's probably because the site owner has limited access to it and you don't have permission to view it. The vast majority of the time, there's not much you can do to fix things on your (*client) end. There are four common causes for 403 Forbidden error (server side) . Here they are listed from most likely to least likely:
  • An empty website directory
  • No index page
  • Incorrect settings in the .htaccess file
  • Permission / Ownership error
If authentication credentials were provided in the request, the server considers them insufficient to grant access. The client SHOULD NOT automatically repeat the request with the same credentials. The client MAY repeat the request with new or different credentials. However, a request might be forbidden for reasons unrelated to the credentials.

Loop
Posts: 169
Joined: 07 Jan 2019, 14:51

Re: WinHTTPRequest status 403

Post by Loop » 16 Aug 2022, 13:40

Thanks, i solved my problem with Chrome.ahk

Post Reply

Return to “Ask for Help (v1)”