This paper is valid for GeneXus X Evolution 3 upgrade 4 or higher. For other versions see here.
In order to authenticate to Twitter, through GAM just follow these steps:
You need to create a "Twitter application" in Twitter site and obtain Consumer Key and Consumer Secret for that application.
Go to the Application Management page of Twitter for developers (https://apps.twitter.com/) and create a new application, as shown in the following figure:
Figure 1. Creating a new Application in Twitter
Figure 2. Configuring Twitter Application: Settings
Figure 3. Configuring Twitter Application: Keys and Access Tokens
Set Callback URL = http://<domain>/ and WEB SITE to your domain (eg.: apps5.genexus.com).
Define "Twitter Authentication Type" using the GAM backend (Authentication Types link).
Enter Consumer Key and Consumer Secret obtained in Twitter developers site.
Figure 4. Configuring Twitter Authentication in GAM backend.
About the CallBack URL configuration in GAM backend:
In NET and Java: You need to enter the complete site URL in the Twitter Authentication Type configuration, including the virtual directory,
for example: http://apps2.genexusx.com/<Web App>
Do not include the "/servlet" in java.
Twitter Authentication Type can be used in Web Applications and in Smart Devices applications also.
In 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 Twitter.
This button is included dinamically, as the Twitter Authentication Type is detected to be defined in the GAM Repository.
Figure 5. GAM Web login.
In case of Smart Devices applications, you need to change the "Login Object for SD" (it is at the Version level and has the "GAMSDLogin" default value) and add a button which will be specifically for this type of authentication.
Inside the event the code associated to this button will include a call to a method of SDActions, named "LoginExternal".
The first parameter that this method receives, takes its value from the Type name defined in the "Authentication Type" definition of the GAM Repository ("Twitter") - see Figure 4.
There's no need to define variables for the parameters, because in this case the only important parameter of "LoginExternal" Method, is the first parameter whose value is always "Twitter".
As happens in web applications, when clicking the "Twitter" button, the Twitter login appears in the device and after you have logged in, the application will load.
What happens really is that after the user authenticates in Twitter, the application redirects to "GAM application" where the user is created using the credentials given to Twitter, and it generates a Session in GAM. User's data is updated taking the information from Twitter in each new login.
After a user has logged in using Twitter, his information can be seen looking at the "Users" information using the GAM Backend.
Figure 6. Work with users in GAM backend.
Important considerations for IOS apps
It's necessary to configure Twitter consumer Key and Twitter consumer secret properties. See Twitter Consumer Key and Twitter Consumer Secret property using GAM for additional information.
1. Twitter API needs the SITE URL to be public and without any port, so if your application is hosted under port 8080 for example, you need to use any kind of proxy or similar (like Apache web server) in order to use port 80. For more details see the additional information at the bottom of this page.
2. The first time a user logs in to Twitter he will probably need to complete a form where he has to enter his e-mail.
Twitter Consumer Key and Twitter Consumer Secret property using GAM
Prototyping applications with Facebook or Twitter Authentication
How to deploy to cloud java applications using Facebook Authentication
GAM Facebook Authentication Type