Connecting to webpages via http proxy with username/password

Good Morning,

is there a way to connect to webpages/sites via basic and any L/O API?

Regards

Zafar

Hello

  • do you really mean http … and not https??
  • do you really mean basic??
  • do you really want to tell everybody between you and $(http:///insecure/website) your username|password in clear-text??

Okay let us assume https. If it is available in basic that would be nice to have. I can do this in python but I preffer basic. VBA has MSXML and WinHTTP libraries. I would rather avoid that if possible. If there is native library for LO using basic that would be appreciated.

https://stackoverflow.com/questions/70052068/python-requests-library-how-to-ensure-https-requests

See also here.
Please note that everything is done within the standard LO installation.

Because I don’t have much experience with platforms other than Windows, I can’t give you any cross-platform solution. But in Windows you could do this easily by using CreateObject(“WScript.Shell”) method and then run a PowerShell script with the WScript.Shell object, e.g. like this, Dim oShell As Object : oShell = CreateObject(“WScript.Shell”) : oShell.Run “powershell -ExecutionPolicy Bypass -File C:\temp\proxytest.ps1”, 1, True
Please make sure you use straight ASCII quotation marks (") in your code
EDIT: without temporary file

# proxytest.ps1
# Ask for proxy address and port
$proxyAddress = Read-Host "Enter proxy address (e.g. proxy.mycompany.local)"
$proxyPort = Read-Host "Enter the proxy port (e.g. 8080)"

# Ask for credentials
$creds = Get-Credential
$netCreds = $creds.GetNetworkCredential()

# Build the proxy URL (http:// is typical for proxy definition, even if target is HTTPS)
$proxyUrl = "http://{0}:{1}" -f $proxyAddress, $proxyPort
$proxy = New-Object System.Net.WebProxy($proxyUrl)
$proxy.Credentials = $netCreds

# Attach proxy to HttpClientHandler
$handler = New-Object System.Net.Http.HttpClientHandler
$handler.Proxy = $proxy
$handler.UseProxy = $true

# Create HttpClient with proxy handler
$client = New-Object System.Net.Http.HttpClient($handler)

# Make a request (replace with your target URL)
$response = $client.GetStringAsync("http://example.com").Result

# Convert HTML response to Base64
$bytes  = [System.Text.Encoding]::UTF8.GetBytes($response)
$base64 = [Convert]::ToBase64String($bytes)

# Build data URL
$dataUrl = "data:text/html;base64," + $base64

# Launch browser with data URL (Edge example)
Start-Process "msedge.exe" $dataUrl
1 Like

see also LibreOffice for enterprises - The Document Foundation Wiki #Proxy_authentication

1 Like