Page 1 of 1

WVBrowser1BasicAuthenticationRequested // Proxy

Posted: Wed Oct 16, 2024 11:43 am
by sodlf159
initialization
GlobalWebView2Loader := TWVLoader.Create(nil);
GlobalWebView2Loader.UserDataFolder := ExtractFileDir(Application.ExeName) + '\CustomCache\' + IntToStr(Random(10000));
GlobalWebView2Loader.ProxySettings.Server := 'http://Host:port'; //http://geo.~~~.com:12321
GlobalWebView2Loader.StartWebView2;


procedure TMDIChild.WVBrowser1BasicAuthenticationRequested(Sender: TObject;
const aWebView: ICoreWebView2;
const aArgs: ICoreWebView2BasicAuthenticationRequestedEventArgs);
var
AuthResponse: ICoreWebView2BasicAuthenticationResponse;
UserNameStr, PasswordStr: string;
begin
var Uri: PWideChar;
if aArgs.Get_uri(Uri) = S_OK then
ShowMessage('Authentication requested for: ' + Uri);

if aArgs.Get_Response(AuthResponse) = S_OK then
begin
UserNameStr := '~~'; // Basic Authentication ID
PasswordStr := '~~'; // Basic Authentication PW

AuthResponse.Set_UserName(PWideChar(UserNameStr));
AuthResponse.Set_Password(PWideChar(PasswordStr));

aArgs.Set_Cancel(0);
end;
end;