In the Control application, there is a feature on the left side menu called "Authentications". In this feature, there are authentication options for the Control application with Facebook, Twitter and PayPal.
For this article, we'll learn how to use Facebook authentication.
1 - After creating a Control application, we will need to create at least one field in the Control application, and then go to the "Authentications" option on the left side menu of the Control application, as highlighted in the image below:
2 - Right in the first option, we will find the Facebook block with the fields that must be filled in for the authentication to work. These fields can be generated through the Facebook page for Developers, and to know the step by step of this generation, you can access the article link below that shows how to generate the App ID and Secret.
3 - In addition to performing the above credentials generation procedure, we also need to enable the URL of our Control application to avoid returning the message described in the image below when we run our application and use Facebook authentication:
To do this, we must go to the option "Login from Facebook -> Settings" on the Facebook for Developers page, and then enable the option "Force OAuth reauthentication on the Web" and add the URL of our Control application in "URls valid OAuth redirect":
4 - Before inserting the information in the App ID and Secret fields, let's create a method that will be inserted later in the Method Return field, which is used for validation after returning from the webservice, as defined in the field description itself. We click on the "+" icon:
5 - We will call the method name "facebook", click on the "Create" button. For the example, let's add a simple alert to the method using the sc_alert() macro just for this validation:
6 - We went back to the "Authentications" option after saving the method, and selected the facebook method in the "Method Return" field that had just been created. In addition, we inserted the credentials that were generated on the Facebook for Developers page, according to the third step:
7 - Once that's done, let's go to the "Toolbar" option on the left side menu of the Control application, as we will need to enable the Facebook authentication button taking it from the left column to the right:
8 - We save the application, generate the source code and execute it. With the application running, let's click on the "Facebook" button that has been enabled for the application. We will be redirected to enter our Facebook account password, and then the authentication will take place: