AutoIt
AutoIt
Configure HTTP Basic Authentication with SecureString
See more REST Examples
Demonstrates Rest.SetAuthBasicSecure, which configures HTTP Basic authentication using SecureString objects instead of plaintext strings.
Background. A SecureString keeps sensitive values encrypted in memory, reducing the window in which credentials appear as readable plaintext. This is otherwise equivalent to SetAuthBasic.
Chilkat AutoIt Downloads
Local $bSuccess = False
$oRest = ObjCreate("Chilkat.Rest")
Local $bTls = True
Local $bAutoReconnect = True
$bSuccess = $oRest.Connect("example.com",443,$bTls,$bAutoReconnect)
If ($bSuccess = False) Then
ConsoleWrite($oRest.LastErrorText & @CRLF)
Exit
EndIf
; SetAuthBasicSecure configures HTTP Basic authentication using SecureString objects, which keep
; the credentials encrypted in memory.
; Normally you would not hard-code secrets in source. You should instead obtain them from an
; interactive prompt, environment variable, or a secrets vault.
$oSsUsername = ObjCreate("Chilkat.SecureString")
$oSsUsername.Append("myUsername")
$oSsPassword = ObjCreate("Chilkat.SecureString")
$oSsPassword.Append("myPassword")
$bSuccess = $oRest.SetAuthBasicSecure($oSsUsername,$oSsPassword)
If ($bSuccess = False) Then
ConsoleWrite($oRest.LastErrorText & @CRLF)
Exit
EndIf
Local $sResponseText = $oRest.FullRequestNoBody("GET","/api/protected")
If ($oRest.LastMethodSuccess = False) Then
ConsoleWrite($oRest.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite($sResponseText & @CRLF)