(AutoIt) HTTP Basic Authentication
Demonstrates how to use HTTP Basic authentication.
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oHttp = ObjCreate("Chilkat.Http")
; To use HTTP Basic authentication:
$oHttp.Login = "myLogin"
$oHttp.Password = "myPassword"
$oHttp.BasicAuth = True
; Run the test using this URL with the credentials above.
; (Works while httpbin.org keeps the test endpoint available.)
Local $sJsonResponse = $oHttp.QuickGetStr("https://httpbin.org/basic-auth/myLogin/myPassword")
If ($oHttp.LastMethodSuccess = False) Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite("Response status code: " & $oHttp.LastStatus & @CRLF)
ConsoleWrite($sJsonResponse & @CRLF)
; Output:
; Response status code: 200
; {
; "authenticated": true,
; "user": "myLogin"
; }
|