Sample code for 30+ languages & platforms
CkPython

HTTP Basic Authentication Test

Demonstrates how to do HTTP basic authentication using Chilkat.

Chilkat CkPython Downloads

CkPython
import sys
import chilkat

# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

http = chilkat.CkHttp()

# To use HTTP Basic authentication:
http.put_Login("myLogin")
http.put_Password("myPassword")
http.put_BasicAuth(True)

# Run the test using this URL with the credentials above.  
# (Works while httpbin.org keeps the test endpoint available.)
jsonResponse = http.quickGetStr("https://httpbin.org/basic-auth/myLogin/myPassword")
if (http.get_LastMethodSuccess() == False):
    print(http.lastErrorText())
    sys.exit()

print("Response status code: " + str(http.get_LastStatus()))

print(jsonResponse)

# Output:

# Response status code: 200
# {
#   "authenticated": true, 
#   "user": "myLogin"
# }