Delphi Microsoft Sign-In Login

 From sgcWebSockets 2022.5.0 there is a new class that simplifies the process of authenticate an user using the Microsft Azure Account as Authentication. The class let you login with your Microsoft Account in an easy way.

Configuration 

The module requires first configure your OAuth2 Application in your Microsoft Account, once are configure just add a couple of lines in your application to allow users login with any Microsoft Account.

The Local Server used to read the response from Google, by default listens on IP Address 127.0.0.1 and port 8080 and SSL enabled. So you must configure the CallBack URL https://localhost:8080 (Microsoft only allows localhost for local URLs) in the Microsoft Application. Of course, you can modify the IP Address and port.

Once configured the OAuth2 Application in the Microsoft Account, just create an instance of TsgcHTTP_OAuth2_Client_Microsoft and call the method Authenticate passing as parameters the TenantIdClient_Id and Client_Secret. This method waits (by default up to 60 seconds) till the user has login successfully. Returns an object where you can check if the user has authenticated or not, the Name, Id... and more data from the user profile.

Delphi Login Microsoft 

procedure MicrosoftSignIn;
begin
var
  oClient: TsgcHTTPComponentClient_OAuth2_Microsoft;
  oData: TsgcOAuth2_Microsoft_Data;
begin
  oClient := TsgcHTTPComponentClient_OAuth2_Microsoft.Create(nil);
  Try
    oData := oClient.Authenticate('tenant_id', 'client_id', 'client_secret');
    if oData.Authenticated then
      ShowMessage(oData.UserProfile.DisplayName);
  Finally
    oClient.Free;
  End;
end; 
×
Stay Informed

When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.

Delphi WhatsApp Cloud API
Delphi Google Sign-In Login

Related Posts