B4X
B4X
HTTP Basic Authentication Test
Demonstrates how to do HTTP basic authentication using Chilkat.Chilkat B4X Downloads
' This example requires the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
Dim http As ChilkatHttp
http.Initialize("http")
' To use HTTP Basic authentication:
http.Login = "myLogin"
http.Password = "myPassword"
http.BasicAuth = True
' Run the test using this URL with the credentials above.
' (Works while httpbin.org keeps the test endpoint available.)
Dim jsonResponse As String = http.QuickGetStr("https://httpbin.org/basic-auth/myLogin/myPassword")
If http.LastMethodSuccess = False Then
Log(http.LastErrorText)
Return
End If
Log("Response status code: " & http.LastStatus)
Log(jsonResponse)
' Output:
' Response status code: 200
' {
' "authenticated": true,
' "user": "myLogin"
' }