(Lianja) HTTP Basic Authentication
Demonstrates how to use HTTP Basic authentication.
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loHttp = createobject("CkHttp")
// To use HTTP Basic authentication:
loHttp.Login = "myLogin"
loHttp.Password = "myPassword"
loHttp.BasicAuth = .T.
// Run the test using this URL with the credentials above.
// (Works while httpbin.org keeps the test endpoint available.)
lcJsonResponse = loHttp.QuickGetStr("https://httpbin.org/basic-auth/myLogin/myPassword")
if (loHttp.LastMethodSuccess = .F.) then
? loHttp.LastErrorText
release loHttp
return
endif
? "Response status code: " + str(loHttp.LastStatus)
? lcJsonResponse
// Output:
// Response status code: 200
// {
// "authenticated": true,
// "user": "myLogin"
// }
release loHttp
|