PureBasic
PureBasic
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 PureBasic Downloads
IncludeFile "CkRest.pb"
Procedure ChilkatExample()
success.i = 0
rest.i = CkRest::ckCreate()
If rest.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
bTls.i = 1
bAutoReconnect.i = 1
success = CkRest::ckConnect(rest,"example.com",443,bTls,bAutoReconnect)
If success = 0
Debug CkRest::ckLastErrorText(rest)
CkRest::ckDispose(rest)
ProcedureReturn
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.
username.s = "myUsername"
password.s = "myPassword"
success = CkRest::ckSetAuthBasic(rest,username,password)
If success = 0
Debug CkRest::ckLastErrorText(rest)
CkRest::ckDispose(rest)
ProcedureReturn
EndIf
; ClearAuth removes any authentication providers and credentials previously configured through the
; SetAuth* methods, for example before reusing the object for an unauthenticated request.
CkRest::ckClearAuth(rest)
Debug "Authentication cleared."
CkRest::ckDispose(rest)
ProcedureReturn
EndProcedure