Sample code for 30+ languages & platforms
AutoIt

Clear REST Authentication Settings

See more REST Examples

Demonstrates Rest.ClearAuth, which removes any authentication providers and credentials previously configured through the SetAuth* methods.

Background. Clearing authentication is useful when reusing a Rest object for a request that must be sent without credentials, or before switching to a different authentication method.

Chilkat AutoIt Downloads

AutoIt
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

;  Normally you would not hard-code secrets in source.  You should instead obtain them from an
;  interactive prompt, environment variable, or a secrets vault.
Local $sUsername = "myUsername"
Local $sPassword = "myPassword"
$bSuccess = $oRest.SetAuthBasic($sUsername,$sPassword)
If ($bSuccess = False) Then
    ConsoleWrite($oRest.LastErrorText & @CRLF)
    Exit
EndIf

;  ClearAuth removes any authentication providers and credentials previously configured through the
;  SetAuth* methods, for example before reusing the object for an unauthenticated request.
$oRest.ClearAuth()

ConsoleWrite("Authentication cleared." & @CRLF)