Skip to content

Login with Twitter

To enable Twitter account log in to your Backendless application:

  1. Create your application at https://developer.twitter.com/en/apps.
  2. In the application's Settings tab, set the Website to https://api.backendless.com
  3. Set the Callback URLs to:
    https://api.backendless.com/YOUR-APP-ID/REST-API-KEY/users/social/oauth/twitter/request_url
    https://api.backendless.com/YOUR-APP-ID/REST-API-KEY/users/social/twitter/authorize
    

    make sure to replace YOUR-APP-ID and REST-API-KEY to the values assigned to your Backendless app.
  4. From the Keys and tokens tab, copy the Consumer API key and the API secret key values.
  5. Click the Permissions tab and select the Request email addresses from users checkbox. Click Update Settings.
  6. Log in to your account in the Backendless Console, select your app and click Manage.
  7. Scroll down to the Social Settings section and insert the values copied on step 4 into the Twitter Consumer key and Twitter Consumer secret fields.

Also see Android and iOS documentation for additional configuration.

Method

Use following code to allow the users to log in to your application with their Twitter account:

Future<BackendlessUser> Backendless.userService.loginWithTwitter(
          String authToken, 
          String authTokenSecret,
          {Map<String, String> fieldsMapping, 
          bool stayLoggedIn, 
          BackendlessUser guestUser}) );

Add the fields mapping with Twitter to allow the users to log in to your application with their Twitter account:

Map twitterFieldsMapping = {
  "name": "twitter_name"
};
Backendless.userService.loginWithTwitter(authToken, authTokenSecret, 
  fieldsMapping: twitterFieldsMapping, stayLoggedIn: stayLoggedIn );

where:

Argument                Description
twitterFieldsMapping a mapping between the Twitter fields and Backendless user properties. Keys must be the names of the Twitter fields, values - the names of the Backendless properties.
stayLoggedIn a boolean value requesting user login information to be saved on the client side, so it can be reused when the application restarts (or page is reloaded).