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.
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
Go to our Awesome Core Settings and create two settings
Paste the Client ID and Client Secret that we have got from the previous step
- Add “linkedin_service” into Awesome Core “services”
- Import “linkedin_service”
Use this link and import the XML for creating the linkedin_service
Go to your “Login” app or any app where you have to implement the social login.
- Add our login button snippet
Note: We are using <template> for setting the cookie, so please make sure that you have spa.js loaded
- Create a module inside your app called “linkedin-handler”
- 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.