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. Add the fields mapping with Twitter to allow the users to log in to your application with their Twitter account:

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).

Method

POST

URI

https://api.backendless.com/<application-id>/<REST-api-key>/users/social/oauth/twitter/request_url

where:

Argument                Description
<application-id> the ID of your application generated upon its creation. You can obtain the value in the Manage > App Settings section of the Backendless Console.
<REST-api-key> REST API key of your application. You can obtain the value in the Manage > App Settings section of the Backendless Console.

Sample Request Body

{  
  "fieldsMapping" : {  
      "userId" : "UserID",  
      "screenName" : "ScreenName"  
   },  
  "redirect" : true  
}

where:

Argument                Description
fieldsMapping 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. Social properties will be copied to the Backendless user properties and should be updated manually in case of their change.
redirect if set to true, the authorization URL will return the '303 See other' response code.

Response Body

HTTP Response: 200 : response contains BackendlessUser object (with all props, except for password).
HTTP Response other than 200 in case of a social authorization, registration or a login error

Example

curl   
-H Content-Type:application/json   
-X POST   
-d'{"fieldsMapping":{"userId":"First", "screenName":"Last"}, "redirect":true}'  
-v https://api.backendless.com/application-id/REST-api-key/users/social/oauth/twitter/request_url