Social Settings

Top  Next

Backendless provides support for logging in users with Facebook or Twitter credentials. Once logged in, Backendless creates a registered user in its internal user storage and links the Backendless user account with his external social account (see the "socialAccount" column in the Users table on the Data screen). To enable social login, a Backendless backend must be configured with API keys.

hmtoggle_plus1Login with Facebook Setup

This configuration is available on the Manage > App Settings screen of the Backendless Console:

backendless-facebook-settings

To obtain your Facebook App ID/API Key and App Secret:

2.Select an application or create one using the "My Apps" dropdown in the upper right corner.
3.Make sure the application is public and available to all users as indicated by the green dot next to the application name:
live-fb-app.zoom50
4.Locate the App ID and App Secret in the Settings section and copy the values into the corresponding fields in the Backendless Console (Manage > App Settings > Social Settings).
5.IMPORTANT: For the Backendless' "Easy Facebook Login" option make sure to make the following changes:
1.Click Settings on your Facebook application page.
2.Enter api.backendless.com into the App Domains field.
3.Make sure the Contact Email field contains a valid email address.
4.If the Website platform is not added, click + Add Platform and select Website.
5.Enter https://api.backendless.com as the Site URL.
After you make the changes described above, the Settings section should look as shown below:
basic-fb-settings.zoom50
6.Click Save Changes.
7.Click the Advanced tab on the Settings section.
8.Scroll down to the Client OAth Settings block and enter https://api.backendless.com into the Valid OAth redirect URIs field
oath-settings.zoom80
9.Scroll to the bottom of the page and click Save Changes.
hmtoggle_plus1Login with Twitter Setup

This configuration is available on the Manage > App Settings screen of the Backendless Console:

twitter-credentials-in-backendless

To obtain your Twitter Consumer key and secret:

1.In a browser, navigate to https://apps.twitter.com/ and sign in with your Twitter account.
2.Click "Create New App":
create-new-app-twitter.zoom60
3.Enter application name and description. For "Website" and "Callback URL" use "https://backendless.com" a shown in the screenshot below:
twitter-app-details.zoom50
4.Once the application is created, click the "API Keys" tab and copy Twitter API key and secret values to the corresponding fields in Backendless console:
twitter-key-and-secret.zoom50
5.This completes the configuration setup. The Backendless backend is now ready to handle Twitter authentication.

 

The steps below demonstrate how Login with Twitter can be tested:

1.Run the following command in a terminal window (if you do not have access to the curl command, a similar request can be created using any REST plugin for Google Chrome). The request performs the Twitter login operation. Once the login is successful, user's account will also be created in the Backendless internal storage. This is the same request which Backendless SDK sends when using the loginWithTwitter method. Notice the "fieldsMapping" parameter - it specified how Twitter user properties will be mapped to Backendless user properties. In this example, Twitter's "userId" property will be presented as "twitterUserIdInBackendless" in the Backendless system. Similarly, Twitter's "screenName" will be saved as "'twitterUserIdInBackendless". Also, make sure to replace YOUR_APP_ID and REST_SECRET_KEY with the specific values for your Backendless backend.

curl -H application-id:YOUR_APP_ID -H secret-key:REST_SECRET_KEY -H application-type:REST -H Content-Type:application/json -X POST -d'{"fieldsMapping":{"userId":"twitterUserIdInBackendless", "screenName":"twitterScreenNameInBackendless"}, "redirect":true}' -v http://api.backendless.com/v1/users/social/oauth/twitter/request_url

2.Once you run the command, look for the Location header in the response.
curl-twitter-test.zoom70
3.Copy the value of the header and paste it into a web browser and authorize the app. This is the same thing that happens when you use Backendless SDK. The implementation opens a page which requests the user to authorize access:
authorize-twitter-app
4.Once the app is authorized by the user, Backendless creates an account for that user in its internal storage system (the Users table). You can see the user in Backendless Console:
twitter-user-account-in-backendless.zoom35

 

 
 


Please let us know how we can improve the documentation by leaving a comment. All technical questions should be posted to the Backendless Support forum. We do not respond to the technical questions on the documentation pages.: