Get access to over 100 FireMonkey cross platform samples for Android, IOS, OSX, Windows, and Linux!

AndroidAppmethodCode SnippetDelphiDemoFiremonkeyIOSOSXWindows

Impliment Basic HTTP Authentication In Delphi XE8 Firemonkey On Android And IOS

Delphi XE8 Firemonkey Basic HTTP Authentication Android IOSDeveloper Al Mannarino from Embarcadero has published a demo on how to implement basic authentication for HTTP in Delphi XE8 Firemonkey. The demo works on Android, IOS, OSX, and Windows. It utilizes the native platform HTTP client component TNetHTTPClient in Delphi XE8. Basic HTTP authentication sends an HTTP header field containing a Base64 encoded user and password. You should use SSL/TLS encryption with your connections if you are using basic HTTP authentication for enhanced security. Unless you are using a session you will need to send the basic HTTP authentication header each time you make an HTTP request. An alternative method is to just POST your username and password via an HTTP request and then set up a session variable which you would pass back to the server on each additional request. You should be able to use this example with Appmethod as well. Here is a code snippet from the demo:

var
LResponse: IHTTPResponse;
BasicAuth: TNetHeader;
begin
if (eUser.Text <> '') or (ePwd.Text <> '') then
begin
BasicAuth := TNetHeader.Create('Authorization',
'Basic ' + Encode64(eUser.Text + ':' + ePwd.Text));
end;
try
LResponse := NetHTTPRequest1.Get(eURL.Text);
m1.Text := LResponse.ContentAsString;
except
on e: Exception do
showmessage(e.Message);
end;

Head over and download the full source code for doing basic HTTP authentication in Delphi XE8 Firemonkey.

Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

Related posts
DelphiDemoFiremonkeyIOSLinuxOSXWindows

Bring OpenAI Agents, Vision, Audio, And Realtime AI To Firemonkey

DelphiIDEWindows

Add AI Pair Programming, Refactoring, And Multi-LLM Workflows To RAD Studio

DelphiDemoFiremonkeyLibraryWindows

Bring OpenAI, Local LLMs, And AI Assistants To FMX Apps

DelphiFiremonkeyLibrary

DelphiGemini Brings Native Google Gemini AI Integration To Delphi

Sign up for our Newsletter and
stay informed
[mailpoet_form id="1"]

Leave a Reply