Skip to content

Login with Twitter

To enable Twitter account log in to your Backendless application:

  1. Create your application at
  2. In the application's Settings tab, set the Website to
  3. Set the Callback URLs to:

    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.
  8. Add Twitter Kit to your project per the instructions from:
  9. The following methods should be used in the client application to perform login with a twitter account:
- (void)loginWithTwitterWithAuthToken:(NSString * _Nonnull)authToken authTokenSecret:(NSString * _Nonnull)authTokenSecret fieldsMapping:(NSDictionary * _Nonnull)fieldsMapping responseHandler:^(BackendlessUser * _Nonnull)responseHandler errorHandler:^(Fault * _Nonnull)errorHandler;
func loginWithTwitter(authToken: String, authTokenSecret: String, fieldsMapping: [String: String], responseHandler: ((BackendlessUser) -> Void)!, errorHandler: ((Fault) -> Void)!)

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

TWTRLogInButton *logInButton = [TWTRLogInButton buttonWithLogInCompletion:^(TWTRSession *session, NSError *error) {
    if (session) {
        [Backendless.shared.userService loginWithTwitterWithAuthToken:session.authToken authTokenSecret:session.authTokenSecret fieldsMapping:@{@"email": @"email"} responseHandler:^(BackendlessUser *loggedInUser) {
            NSLog(@"User has been logged in with Twitter: %@",;
        } errorHandler: ^(Fault *fault) {
            NSLog(@"Error: %@", fault.message);
    else {
        NSLog(@"Twitter login failed: %@", [error localizedDescription]);
}]; =;
[self.view addSubview:logInButton];
let logInButton = TWTRLogInButton(logInCompletion: { session, error in
    if let session = session {
        Backendless.shared.userService.loginWithTwitter(authToken: session.authToken, authTokenSecret: session.authTokenSecret, fieldsMapping: ["email": "email"], responseHandler: { user in
            print("User has been logged in with Twitter: \(")
        }, errorHandler: { fault in
            print("Error: \(fault.message ?? "")")
    else {
        print("Twitter login failed: \(error!.localizedDescription)");
}) =


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