Creating a LinkedIn Application
The very first step ter integrating LinkedIn authentication with your webstek is to create a LinkedIn application. To do so, go to LinkedIn Developer Network and create a fresh application. The following figure shows the main application creation pagina.
Main Application Creation Pagina
While there are many mandatory fields of the above form, the sections highlighted above are significant. Especially, notice the Webstek URL and Default Scope entries. The Webstek URL should contain a URL that identifies your webstek. During development you can use a localhost based path such spil http://localhost:12345. However, merienda the development is overheen you should switch it to a positivo webstek address. The default scope area is used to indicate the default set of permissions that a user voorwaarde grant to the application being created. Ter the above figure a user voorwaarde share his basic profile information with the application being created.
Getting an Application API Key
Merienda you inject all the required fileds, klapper Save to create the application. Upon successful creation you will also be shows details such spil API Key and Secret Key. Ter this example API Key is sufficient and you should note it down somewhere before going ahead. The following figure shows the area where API Key is shown:
The authorize setting controls whether a user should sign-in to the application even if he has previously granted permissions to the application under consideration. Set authorize to true.
Displaying the Sign-in Button
A webstek with LinkedIn authentication will usually present a button to the end user that hints that the user is supposed to supply his LinkedIn credentials te order to sign-in. To render such a button you can add the following script ter the web pagina.
Setting the type attribute to ter/Login does the trick and you get a sign-in button like this:
You can place the above <,script>, block anywhere you wish to display the sign-in button. When a user clicks this Sign-in button, another browser window opens that shows the LinkedIn sign-in pagina where he can supply his LinkedIn credentials (see below).
Linked-In Sign-In Pagina
The LinkedIn authentication is based on OAuth Two and is treated by LinkedIn. If the user supplies valid credentials he is signed-in to LinkedIn and the sign-in window is closed.
Wiring Auth Event Handler
Retrieving a User Profile
Spil mentioned earlier OnLinkedInAuth() function is called when a user successfully signs-in to the system. Merienda a user is authenticated you can go ahead and read his profile details. To grab the profile details you use the “mij” keyword. The following code shows how this is done.
The ShowProfileData() function is shown below:
Spil you can see the ShowProfileData() functions receives the profile’s parameter. To get the profile of the “mij” user (current user) you use profiles.values and store it ter a member variable. You can then access various lumps of information such spil id, firstName, lastName, pictureUrl and headline. There are many more chunks of information that you can retrieve depending on the permissions granted by a user. A list of all the possible fields can be obtained here. What to do with the profile gegevens retrieved depends on your need. For example, you may store thesis details te your webstek’s database or take the user to your webstek’s registration pagina and pre-populate certain fields.