Table of contents

 


i
This is not the latest version of this document; to access the latest version, click here.
Official Content

GeneXus Access Manager (GAM) provides a way to authenticate using Facebook. For X Evolution 3 Upgrade 4 or upper, see Facebook Authentication Type.

Steps to follow

1. Create a "Facebook client application" on Facebook site and obtain App Id and App Secret for that application.

Go to Facebook for developers (http://developers.facebook.com/) > My apps > Add a new app, as shown in the following figures:

Fb1_png
Fb2_png
Fb3_png
Fb4_png
Fb5_png
Fb61_png


Note that you need to configure the Site URL = http://<domain> (http://apps2.genexusx.com) (eg.: apps5.genexus.com).

2. Define "Facebook Authentication Type" using the GAM backend. Go through Authentication Types link.

Fb7_png

Facebook API needs the SITE URL to be different than "localhost" and the default port needs to be 80. If your application is hosted under port 8080, you need to use a proxy or similar (like Apache web server) in order to use port 80.

Important note:

  • In the case of Java and .NET you need to enter the complete site URL in Site URL. For example:  http://apps2.genexusx.com/Ide1b858bf3b044ba0ac777119780e4370/servlet  (Java) or http://apps3.genexusx.com/Ide1b858bf3b044ba0ac777119780e4370  (.NET)
  • In the case of Ruby you need to specify in SITE URL only the server, not the complete URL, for example, http://apps2.genexusx.com

Facebook Authentication Type can be used in Web Applications and Smart Devices applications also.

Web Applications

In the case of Web Applications, the GamExampleLogin object (which is part of the GAM - Examples) includes automatically a button by which the user can login to Facebook.
This button is included dynamically, as the Facebook Authentication Type is already defined in the GAM Repository.

The code associated to that button, which authenticates to Facebook, is as follows:

Event &ButtonFacebook.Click
    GAMRepository.LoginFacebook()
EndEvent

loginFace

SD Applications

In the case of Smart Devices applications, you need to add an event in the login object in order to authenticate using Facebook.

The logic inside the event associated will include a call to a method of SDActions External Object, named "LoginExternal".

The first parameter this method receives has to take its value from the Type name defined in the "Authentication Type" definition of the GAM Repository ("Facebook").

Event 'facebook'
composite
    SDActions.LoginExternal("Facebook","","")
    return
endcomposite
EndEvent

For more information, see:

Software Requirements

  •     Java: JDK 1.7 or upper is required to be installed on the application server. Otherwise, the Facebook certificate has to be installed in the key store of the JVM.
  •     Csharp: The certificate of Facebook has to be installed on the Windows server.
  •     Ruby: Add the Facebook certificate to the Apache configuration.

Note

1. Facebook Authentication is solved using OAuth.

2. In case you want to "work with friends", or do any particular action after the user has logged in, you need to communicate with the Facebook API. In that case, you'll probably need to get the ExternalToken method of GAMSession EO. The result of invoking this method should be passed to the Facebook API.

See Also

GAM - Facebook Interaction Sample
Prototyping applications with Facebook or Twitter Authentication
GAM - Twitter Authentication Type
Additional Scope Property for GAM Google / Facebook Authentication Types

Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant