Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Login through the Google API



Permlink Replies: 4 - Last Post: Feb 7, 2017 8:08 AM Last Post By: Frederick Couto
Frederick Couto

Posts: 9
Registered: 12/17/09
Login through the Google API
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 12, 2016 12:47 PM
Hello,

Gentlemen, I am implementing a website where I want to put the user to log in via Google or Facebook API , I wonder if anyone has implemented this behavior or if anyone has any tips to help me.

I'm having a little trouble to find some stuff to help me with this.

I am using Delphi 10 Seattle with intraweb 14.0.52

I thank the attention.
Alexander Popov

Posts: 52
Registered: 7/22/05
Re: Login through the Google API
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 13, 2016 4:51 AM   in response to: Frederick Couto in response to: Frederick Couto
Hi!

You can use TOAuth2Authenticator component from REST Client component pane.

You have to get ClientId and ClientSecret codes from your authentication provider (Google, Facebook, etc) as well as AccessTokenEndPoint and AuthorizationEndPoint and specify it in the corresponding properties of OAuth2Authenticator. Specify an arbitrary RedirectionEndPoint, for example http://mysite.com/?auth_success.

Consider that you will try to use the external authentication when you find 'ext_auth' parameter in the url.
Then, your code will be like this:

procedure TIWUserSession.IWUserSessionBaseCreate(Sender: TObject);
var Code: String;
begin
  if WebApplication.RunParams.IndexOf('auth_success') <> - 1 then begin
    Code := WebApplication.RunParams.Values['code'];
    if Code <> '' then begin
      OAuth2Authenticator1.AuthCode := Code;
      OAuth2Authenticator1.ChangeAuthCodeToAccesToken;
      TfrmLoginSuccess.SetAsMainForm;
    end
    else begin
      TfrmLoginFailed.SetAsMainForm;
    end;
  end
  else begin
     if WebApplication.RunParams.IndexOf('ext_login') <> - 1 then begin
       WebApplication.TerminateAndRedirect(OAuth2Authenticator1.AuthorizationRequestURI);
     end
     else begin
       TIWForm1.SetAsMainForm;
     end;
  end;
end;


Note, that if you use https and standalone server you must have OpenSSL dlls in your working directory (where your EXE file resides).

Frederick Couto wrote:
Hello,

Gentlemen, I am implementing a website where I want to put the user to log in via Google or Facebook API , I wonder if anyone has implemented this behavior or if anyone has any tips to help me.

I'm having a little trouble to find some stuff to help me with this.

I am using Delphi 10 Seattle with intraweb 14.0.52

I thank the attention.

Edited by: Alexander Popov on Jul 13, 2016 4:52 AM
Frederick Couto

Posts: 9
Registered: 12/17/09
Re: Login through the Google API
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 14, 2016 3:09 PM   in response to: Alexander Popov in response to: Alexander Popov
Alexander Popov wrote:
Hi!

You can use TOAuth2Authenticator component from REST Client component pane.

You have to get ClientId and ClientSecret codes from your authentication provider (Google, Facebook, etc) as well as AccessTokenEndPoint and AuthorizationEndPoint and specify it in the corresponding properties of OAuth2Authenticator. Specify an arbitrary RedirectionEndPoint, for example http://mysite.com/?auth_success.

Consider that you will try to use the external authentication when you find 'ext_auth' parameter in the url.
Then, your code will be like this:

procedure TIWUserSession.IWUserSessionBaseCreate(Sender: TObject);
var Code: String;
begin
  if WebApplication.RunParams.IndexOf('auth_success') <> - 1 then begin
    Code := WebApplication.RunParams.Values['code'];
    if Code <> '' then begin
      OAuth2Authenticator1.AuthCode := Code;
      OAuth2Authenticator1.ChangeAuthCodeToAccesToken;
      TfrmLoginSuccess.SetAsMainForm;
    end
    else begin
      TfrmLoginFailed.SetAsMainForm;
    end;
  end
  else begin
     if WebApplication.RunParams.IndexOf('ext_login') <> - 1 then begin
       WebApplication.TerminateAndRedirect(OAuth2Authenticator1.AuthorizationRequestURI);
     end
     else begin
       TIWForm1.SetAsMainForm;
     end;
  end;
end;


Note, that if you use https and standalone server you must have OpenSSL dlls in your working directory (where your EXE file resides).

Frederick Couto wrote:
Hello,

Gentlemen, I am implementing a website where I want to put the user to log in via Google or Facebook API , I wonder if anyone has implemented this behavior or if anyone has any tips to help me.

I'm having a little trouble to find some stuff to help me with this.

I am using Delphi 10 Seattle with intraweb 14.0.52

I thank the attention.

Edited by: Alexander Popov on Jul 13, 2016 4:52 AM

Alexander , thanks for the feedback.

After several attempts and consultations on the Internet , I could not even put to work by chance know where I can find some example of this procedure.

Thank you!

Daniel Fields

Posts: 622
Registered: 11/29/04
Re: Login through the Google API
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 18, 2016 11:15 AM   in response to: Frederick Couto in response to: Frederick Couto
I believe they have that feature in the TMS Cloud Pack. The components provide access to cloud services from your IW application. There are components for Google, Microsoft, Dropbox, FourSquare, Twitter, Facebook, LinkedIn, Amazon and a few others. I have just installed this product and started to try it out. It looks to have many features for each service.

http://tmssoftware.com/site/tmsiwcloud.asp
Frederick Couto

Posts: 9
Registered: 12/17/09
Re: Login through the Google API
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 7, 2017 8:08 AM   in response to: Daniel Fields in response to: Daniel Fields
Daniel Fields wrote:
I believe they have that feature in the TMS Cloud Pack. The components provide access to cloud services from your IW application. There are components for Google, Microsoft, Dropbox, FourSquare, Twitter, Facebook, LinkedIn, Amazon and a few others. I have just installed this product and started to try it out. It looks to have many features for each service.

http://tmssoftware.com/site/tmsiwcloud.asp

Good afternoon everyone,

I wonder if anyone here has used the AdvFacebook component of TMS, I'm trying to get the user to sign in to the site through Facebook or Google.

I made the implementations according to the existing Demo of the TMS_Cloud_Pack_v.2.5.1.1_XE-XE7_XE10_Src package and when I use it in the form of the StandAlone Application it works normally.

My problem is when I run through the IIS DLL (ISAP Extension), it is always returning the error "Could not get OLE control window handle."

Case wanna take a look at the site is http://www.curtomoto.com.br/ the error occurs when clicking the link to login, there will have an iwbutton1 (this provisional of course) where clicking the error occurs.

I use Delphi 10 Seattle with Intraweb 14.0.63.

Thank you all for your attention!

Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02