Sample code for 30+ languages & platforms
PowerShell

HTTP Basic Authentication Test

Demonstrates how to do HTTP basic authentication using Chilkat.

Chilkat PowerShell Downloads

PowerShell
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"

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

$http = New-Object Chilkat.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.)
$jsonResponse = $http.QuickGetStr("https://httpbin.org/basic-auth/myLogin/myPassword")
if ($http.LastMethodSuccess -eq $false) {
    $($http.LastErrorText)
    exit
}

$("Response status code: " + $http.LastStatus)

$($jsonResponse)

# Output:

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