Sample code for 30+ languages & platforms
Lianja

HTTP Basic Authentication Test

Demonstrates how to do HTTP basic authentication using Chilkat.

Chilkat Lianja Downloads

Lianja
// This example requires 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