Skip to content

Twitter support

First of all you need to have your API credentials ready by creating an app on Twitter. Then add them to your para-application.conf configuration file:

para-application.conf
para.tw_app_id = "..."
para.tw_secret = "..."

Or add these through the app settings API:

{
"tw_app_id": "..."
"tw_secret": "..."
"signin_success": "http://success.url"
"signin_failure": "http://failure.url"
}

Para can return a short-lived ID token back to the client which initiated the request. Add jwt=id to your signin_success url. For example { "signin_success": "http://success.url?jwt=id" }. The id value of the parameter will be replaced with the actual JWT ID token, which you can use to call paraClient.signIn("passwordless", idToken) to get the long-lived session token.

Support for logging in with Twitter is implemented by the TwitterAuthFilter. This filter responds to requests at /twitter_auth.

The endpoint expects an appid value from the ‘state’ parameter, e.g. ?state={appid}. If that parameter is missing, the default (root) app will be used as authentication target.

To initiate a login with Twitter just redirect the user to the /twitter_auth. This will redirect the user to Twitter for authentication. For apps other than the root app, redirect to /twitter_auth?state=myapp.

Below is an example Javascript code for a Twitter login button:

$("#twitterLoginBtn").click(function() {
window.location = "/twitter_auth";
// for apps other than the root app use:
// window.location = "/twitter_auth?state=" + APPID;
return false;
});