Visual FoxPro
Visual FoxPro
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 Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loRest
LOCAL lnBTls
LOCAL lnBAutoReconnect
LOCAL loSsUsername
LOCAL loSsPassword
LOCAL lcResponseText
lnSuccess = 0
loRest = CreateObject('Chilkat.Rest')
lnBTls = 1
lnBAutoReconnect = 1
lnSuccess = loRest.Connect("example.com",443,lnBTls,lnBAutoReconnect)
IF (lnSuccess = 0) THEN
? loRest.LastErrorText
RELEASE loRest
CANCEL
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.
loSsUsername = CreateObject('Chilkat.SecureString')
loSsUsername.Append("myUsername")
loSsPassword = CreateObject('Chilkat.SecureString')
loSsPassword.Append("myPassword")
lnSuccess = loRest.SetAuthBasicSecure(loSsUsername,loSsPassword)
IF (lnSuccess = 0) THEN
? loRest.LastErrorText
RELEASE loRest
RELEASE loSsUsername
RELEASE loSsPassword
CANCEL
ENDIF
lcResponseText = loRest.FullRequestNoBody("GET","/api/protected")
IF (loRest.LastMethodSuccess = 0) THEN
? loRest.LastErrorText
RELEASE loRest
RELEASE loSsUsername
RELEASE loSsPassword
CANCEL
ENDIF
? lcResponseText
RELEASE loRest
RELEASE loSsUsername
RELEASE loSsPassword