Unofficial Content
  • This documentation is valid for:

How to test Facebook Authentication TypeTwitter Authentication for Java applications, taking into account the considerations explained in Prototyping applications with Facebook or Twitter Authentication.

In order to test Facebook or Twitter authentication, the URL of the application should not be "localhost" and shouldn´t have reference to the port (for example, http://localhost:8080 is not a valid URL, neither http://localhost, nor http://server:8080). 

But if you want to test locally you need to make some changes in hosts file of the PC, and of the emulator.
Besides, you need to intall a web server that listens on port 80 and connect this web server to the Tomcat server.

WEB applications

1. Edit hosts file (C:\Windows\System32\drivers\etc)

Add the following line:

127.0.0.1       gamtestjava.com

2. Install Apache web server. This server needs to be connected to Tomcat using modproxy.

Apache listens on port 80 and redirects to Tomcat on port 8080.

Changes in httpd.conf (Apache configuration file) will be as follows:

NameVirtualHost *:80

# Domain gamtestjava.com - redirects to Tomcat
<VirtualHost *:80>
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/gamtestjava"
ServerName gamtestjava.com

<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/gamtestjava">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all

</Directory>
ProxyPass / http://gamtestjava.com:8080/
ProxyPassReverse / http://gamtestjava.com:8080/
</VirtualHost>

3. Define facebook application in Facebook site as the following:

GAMfacebookjava

Figure 1.

4. Define facebook application in GAM Backend as the following:

GAMFacebookBackendjava

Figure 2.

Note (figure 2) that you need to specify the complete URL - including virtual directory.

Important:

The URL of execution must be the same as the one configured in the GAM backend, and the same base URL configured in Facebook site, as shown in figure 3.

URLexecutionjavaGAMFace

In case you don´t execute using the URL indicated, you get runtime errors because Facebook requires that the URL of the request is the same as the URL given to return.

Figure 3.

So, change the web root generator property in GeneXus, as follows:

webrootjavafacebookgam

Figure 4.

Smart Devices Applications

In order to test your Smart Devices application on Android Emulator, authenticating with Facebook, you need to follow the same steps explained above (for WEB applications) and the steps explained here: Testing Facebook / Twitter authentication for SD applications using Android Emulator.

In our example, the server name included in the hosts file of Android SDK will be "gamtestjava.com".

Take into consideration that you need to specify Services URL smart devices generator property as the following:

servicesURLjavaAndroidGAM

Figure 5.

So, in execution, the URL shown will be like the following:

javaApponAndroidemulator

Figure 6.

In case you don´t execute using the URL indicated, you get runtime errors because Facebook requires that the URL of the request is the same as the URL given to return.

It could be useful to test this URL inside the emulator: http://gamtestjava.com, it should redirect to the web server. 

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