Classic ASP
Classic ASP
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 Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0
set rest = Server.CreateObject("Chilkat.Rest")
bTls = 1
bAutoReconnect = 1
success = rest.Connect("example.com",443,bTls,bAutoReconnect)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( rest.LastErrorText) & "</pre>"
Response.End
End If
' 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.
set ssUsername = Server.CreateObject("Chilkat.SecureString")
success = ssUsername.Append("myUsername")
set ssPassword = Server.CreateObject("Chilkat.SecureString")
success = ssPassword.Append("myPassword")
success = rest.SetAuthBasicSecure(ssUsername,ssPassword)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( rest.LastErrorText) & "</pre>"
Response.End
End If
responseText = rest.FullRequestNoBody("GET","/api/protected")
If (rest.LastMethodSuccess = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( rest.LastErrorText) & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( responseText) & "</pre>"
%>
</body>
</html>