Documentation / Tutorials / Generic

How to do social authentication using linkedin

/ Generic / How to do social authentication using linkedin

We can authenticate our application users through our local authentication mechanisms such as traditional username, password, or OTP-based authentication but in this approach, we are the one who is checking the authenticity of the user. But what if someone is already verified the authenticity of a user or somebody else can !. This is where social login authentication comes into action.

Step 1:

Here we are discussing LinkedIn social authentication. First of all, we have to create an app in https://www.linkedin.com/developers/.

Once you have created the app, configure the app with the authorized domain, authorized redirect URLs, and OAuth 2.0 Scopes (r_emailaddress and r_liteprofile). For the scopes, you may have to add the SignIn product from the products tab. Once you have configures the above ones you should copy the Client ID and Client Secret.

Sample redirect URL: https://example.com?social_auth=linkedin

Use below screen snippets for a hustle free setup

#1 – Create App

#2 – Set Domain

#3 – Set Redirect URIs (Inside Auth Tab)

#4 – Add Sign In with LinkedIn Product into your app

#5 – Make sure that you have these scopes

Step 2:

Go to our Awesome Core Settings and create two settings

  • opt-linkedin-id
  • opt-linkedin-secret

Paste the Client ID and Client Secret that we have got from the previous step

Step 3:

  1. Add “linkedin_service” into Awesome Core “services”
  2. Import “linkedin_service”

    https://raw.githubusercontent.com/WPoets/awesomeapps/main/services/linkedin/linkedin_service%20.xml
    Use this link and import the XML for creating the linkedin_service

Step 4:

Go to your “Login” app or any app where you have to implement the social login.

  1. Add our login button snippet

    Note: We are using <template> for setting the cookie, so please make sure that you have spa.js loaded
  2. Create a module inside your app called “linkedin-handler”

     
  3. Process your user data and do the necessary changes to your code
    Eg: Once you have the user data you can set the session

    In the previous step we got out authenticated user data, but that’s not the end of the story. You will have to set the session for this user or you may respond with a bearer token or a JWT depends on what kind of application you are building.
Categories
Most Popular

Leave a Reply

Your email address will not be published.