To authenticate to Twitter using GAM, follow the steps below:
You need to create a "Twitter application" on the Twitter website and get a 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, considering the following settings:
Figure 1. Configuring Twitter Application: Settings
Important: Set Callback URL = http://<domain>/oauth/gam/callback
and WEB SITE to your domain (eg.: apps5.genexus.com).
Figure 2. Configuring Twitter Application: Keys and Access Tokens
From here you will obtain a "Consumer Key" and "Consumer Secret".
Define the "Twitter authentication type" using the GAM backend (Authentication Types link).
Enter the Consumer Key and Consumer Secret obtained on Twitter's developer website.
Important note
About the CallBack URL configuration in GAM Backend: you only need to enter the domain of the server running the application.
It isn't necessary to enter the complete website URL. However, if you enter it, do not include the "/servlet" in Java.
*This authentication type it's not allowed in Angular Generator.
Twitter authentication type can be used in Web Applications and in Native Mobile applications.
See the GAMExampleLogin object for details about how login is executed.
In the case of Native Mobile applications, you need to add an event in the login object to authenticate using Twitter.
The logic inside the associated event will include a call to a method of the Actions external object named "LoginExternal".
The first parameter is based on the GAMAuthenticationTypes domain, and its value should be "Twitter".
The &User and &password parameters are ignored in this case.
The &LoginExternalAdditionalParameters parameter has an "AuthenticationTypeName" property where you can set the name of the Authentication Type. This is because more than one Twitter authentication type can be defined in the Repository.
Event 'Twitter'
Composite
&LoginExternalAdditionalParameters.AuthenticationTypeName = !"Twitterb"
GeneXus.SD.Actions.LoginExternal(GAMAuthenticationTypes.Twitter, &User, &Password, &LoginExternalAdditionalParameters)
Return
EndComposite
EndEvent
Below is another way to program the Twitter login when you only have one Twitter authentication type in the repository (without passing the &LoginExternalAdditionalParameters):
Event 'Twitter'
Composite
GeneXus.SD.Actions.LoginExternal(GAMAuthenticationTypes.Twitter, &User, &Password)
Return
EndComposite
EndEvent
See GAM Login Method for details.
It is necessary to configure the Twitter Consumer Key and Twitter Consumer Secret properties. See Twitter Consumer Key and Twitter Consumer Secret property using GAM for additional information.
1. The Twitter API needs the SITE URL to be public and without any port; therefore, 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 users log in to Twitter, they will probably need to complete a form where they have to enter their email.
3. Important: If you don't set a callback URL = http://<domain>/oauth/gam/callback you may get the following errors:
Twitter Consumer Key and Twitter Consumer Secret property using GAM
Facebook Authentication Type
Google Authentication Type