Unicode C
Unicode C
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 Unicode C Downloads
#include <C_CkRestW.h>
void ChilkatSample(void)
{
BOOL success;
HCkRestW rest;
BOOL bTls;
BOOL bAutoReconnect;
const wchar_t *username;
const wchar_t *password;
success = FALSE;
rest = CkRestW_Create();
bTls = TRUE;
bAutoReconnect = TRUE;
success = CkRestW_Connect(rest,L"example.com",443,bTls,bAutoReconnect);
if (success == FALSE) {
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
return;
}
// 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 = L"myUsername";
password = L"myPassword";
success = CkRestW_SetAuthBasic(rest,username,password);
if (success == FALSE) {
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
return;
}
// ClearAuth removes any authentication providers and credentials previously configured through the
// SetAuth* methods, for example before reusing the object for an unauthenticated request.
CkRestW_ClearAuth(rest);
wprintf(L"Authentication cleared.\n");
CkRestW_Dispose(rest);
}