PowerBuilder
PowerBuilder
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 PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Rest
integer li_BTls
integer li_BAutoReconnect
string ls_Username
string ls_Password
li_Success = 0
loo_Rest = create oleobject
li_rc = loo_Rest.ConnectToNewObject("Chilkat.Rest")
if li_rc < 0 then
destroy loo_Rest
MessageBox("Error","Connecting to COM object failed")
return
end if
li_BTls = 1
li_BAutoReconnect = 1
li_Success = loo_Rest.Connect("example.com",443,li_BTls,li_BAutoReconnect)
if li_Success = 0 then
Write-Debug loo_Rest.LastErrorText
destroy loo_Rest
return
end if
// Normally you would not hard-code secrets in source. You should instead obtain them from an
// interactive prompt, environment variable, or a secrets vault.
ls_Username = "myUsername"
ls_Password = "myPassword"
li_Success = loo_Rest.SetAuthBasic(ls_Username,ls_Password)
if li_Success = 0 then
Write-Debug loo_Rest.LastErrorText
destroy loo_Rest
return
end if
// ClearAuth removes any authentication providers and credentials previously configured through the
// SetAuth* methods, for example before reusing the object for an unauthenticated request.
loo_Rest.ClearAuth()
Write-Debug "Authentication cleared."
destroy loo_Rest