LinkedIn

LinkedIn is the world's largest professional networking website. This company is wholly owned by Microsoft in the year of 2016. This platform is primarily used for building connections in your industry and staying in touch with colleagues, past, and present. LinkedIn will help you to get opportunities by showcasing your unique skills, experience, and education. It can also be used to organize events, post updates, and lots more. This platform can be used in mobile apps and websites.

Authorization

OAuth 2.0 Authentication

LinkedIn is an Identify Provider of your application. You can log in with your Google, Facebook, or GitHub account. To authenticate LinkedIn you need to follow the below steps:

  • Create a LinkedIn app

  • Create an application that can authenticate users with LinkedIn

To create a LinkedIn app you first need to visit the below link: https://www.linkedin.com/developers/

Now, you need to log in with your LinkedIn Account. Sign in to your LinkedIn account for creating your app.

After the completion of the login process now, you need to create the app. Fill in the fields of the app and press the create app button:

To create the app you will need the company’s LinkedIn page. If you don’t have it, then please press the button: + Create a new LinkedIn Page

Please note, If need to enter a valid LinkedIn page to avoid getting an error.

After this step, you will be able to get the LinkedIn app dashboard.

Now, you need to verify your app. This is required, as LinkedIn wants to be sure that this app belongs to the company page that has been selected by you at the time of the App creation. After clicking on this button you will get a verification URL, and by visiting this URL you will be able to verify this app.

Now, you need to sign in with your LinkedIn account to visit the app. Go to the dashboard and visit the products tab to select the Sign In with LinkedIn Product. The product can be added after the completion of the legal agreement acceptance. You will now have to wait for the approval of your LinkedIn product addition. After the completion of this step you will be able to view this in your product tab:

You can see the status of the product is in Review in Progress, therefore you have to wait for it. This process will take a time of few minutes.

You should view this product on the list of your products after the approval:

Now, you need to get the Client ID and Client Secret. Also, add the direct URL.

In the Auth ta,b you will have the access to your Client ID and Client Secret these information you will be needed to authenticate users with LinkedIn.

Here, you will also be needed to add a redirect URL to the list of Redirect URLs:

 

Scopes

A scope is a mechanism in OAuth 2.0 authentication, that limit application’s that help you to access a user’s account. An application can request one or more scopes, it can be presented to the user’s consent screen. The access token can be issued to the application that will be limited to the granted scopes.

The scopes are another vital part of authentication. Be sure that you have access to these scopes:

Now, you need to create an express app that can authenticate users with LinkedIn.

Creating an express application:

Now, initiate passport and express session for authentication

PassportJS is a well-known library for handling authentication. Express-session is another library that helps us keep track of users by using cookies.

If you are not familiar with these libraries there is no problem you can just see the implementation and the description, the implementation is easy.

To use the Passport you need to implement serializeUser and deserializeUser functions. You can passed the user by encrypt this data or can do whatever you need.

Now, you need to Implement LinkedIn Passport Strategy. Passport let us implement the strategies of authentication and there are more than 500 strategies that you can find on their website. Here I used the passport-linkedin-oauth2 strategy.

The ClientID and ClientSecret information is available in your LinkedIn dashboard, you will get the information from the Auth tab.

To get the CallbackURL you need to implement the endpoint and also needed to add it in the list of Redirect URLs in your LinkedIn Auth tab.

The Scope can be found under the Auth tab all the permissions can be view under this field. The Scope is used for providing access.

After the successful authentication, it returns the arguments of this function. We passed the LinkedIn profile to done function so this is going to be the user object.

Parameter

Type

Description

Required

Parameter

Type

Description

Required

Response_type

string

The value of this field should always be: code

Yes

Client_id

string

The API Key value generated when you registered your application.

Yes

Redirect_uri

url

The URI your users are sent back to after authorization. This value must match one of the Redirect URLs defined in your application configuration. For example, https://dev.example.com/auth/linkedin/callback.

Yes

State

string

A unique string value of your choice that is hard to guess. Used to prevent CSRF. For example, state=DCEeFWf45A53sdfKef424.

No

Scope

string

URL-encoded, space-delimited list of member permissions your application is requesting on behalf of the user. These must be explicitly requested. For example, scope=r_liteprofile%20r_emailaddress%20w_member_social. See Permissions and Best Practices for Application Development for additional information.

Ye

 

For more information please visit: LinkedIn Oauth 2.0 Documentation

API key Authentication

The API key helps to identify the calling project for the application or site, this authentication process is used for making the call to an API. This authentication tokens identify a user, a person that used the app or site. This key are supplied by the Client Users and applications calling REST APIs for tracking and controlling the use of the APIs. With the help of the Authenticate API key filter will enables you to authenticate the API key with the API gateway securely. The API key include a key ID for identify the client responsibility based on the API service request. This Authenticate API key needs to be secret, and must be involved with a each request. A confidential secret key can be used to authenticate the API key. The filter of the Authenticate API key can be used to filter the specify where to identify the API key ID and secret key in the request message, this specify the timestamp and options for expiry.

To enable the API key Authentication, you need to first login to the LinkedIn account.

Navigate to the Linked LinkedIn Developers field and login to your LinkedIn account

Now, click on the Create Application. You need to Login again, if required.

You need to fill the app name, privacy policy URL, logo as mentioned below.

Once done you need to click on the create app as shown below.

Key

Description

Key

Description

App Name

Specify the name of your app (You can enter whatever name you like, but it’s recommended to enter your website or company name in this field)

Linkedin Page

URL of the LinkedIn Page associated to your company

Privacy Policy URL

Optionally, you can save privacy policy URL of your website here

App Logo

Logo of your company/website

Now, you need to navigate to the Auth section.

You need to configure your application in the LinkedIn Developer Portal to obtain the Client ID and Client Secret. Now, click on the eye icon after the client secret, you need to copy the client id and client secret for accessing LinkedIn. paste these in the LinkedIn client ID and Client Secret option from the social login page.

After authentication, LinkedIn's authorization server passes an authorization code to your application. Access your website homepage, and click on the address bar for highlighting the website URL. Your application will send this code to LinkedIn and the it will return the access token.

Click the edit icon in front of Redirect URLs option and save this URL in the option.
For example, if http://mywebsite.com is the homepage URL of your website, you need to add http://mywebsite.com/?SuperSocializerAuth=Linkedin or http://mywebsite.com/?HeateorSlAuth=Linkedin in the Redirect URLs option. Now, click on the update button. Your application uses this token to make API calls on behalf of the member.

Now, you need to navigate to the product section for selecting the products. Sign in with your LinkedIn to perform the process.

Provide the confirmation for the addition of the additional products.

For more information please visit: LinkedIn Authentication

LinkedIn Connections

OAuth 2.0 Connection

 

Input 

Key 

Description

Example

Select application

application

Select LinkedIn application

LinkedIn

Connection type

connection type

Select the type of connection.

 REST

REST connection type

rest connection type

Select the type of REST connection.

 OAuth2.0

Connection name

name

Provide a name for the connection.

LinkedIn connection

Connection description

description

Provide a description for the connection.

 

Host name

host 

Provide a string value for the URL of the user's LinkedIn account.

 

Grant type

grant type

Provide the grant type - authorization code, password, client credentials.

 

API Key Connection

 

Input 

Key 

Description

Example

Select application

application

Select LinkedIn application

LinkedIn

Connection Mode

mode

Select custom connection mode

Custom

Connection type

connection type

Select the type of connection.

 REST

REST connection type

rest connection type

Select the type of REST connection.

 API Key

Connection name

name

Provide a name for the connection.

 LinkedIn connection

Connection description

description

Provide a description for the connection.

 

Host name

host 

Provide a string value for the URL of the user's LinkedIn account.

 

Key

key

Provide the key for the connection.

 

Value

value

Add the value for the connection

 

Header Parameter

header

Header parameters are used for user-defined custom HTTP headers for a request.

 

Query Parameter

query

Query parameters are a defined set of parameters attached to the end of a URL.

 

Actions

Share a Post

Share a post | key: sharePost

 

Key

Description

Example

Key

Description

Example

User ID

Provide the user id of the user to sign in on LinkedIn.

Oj0Eoqh

Content to be posted

Add the specific content that needs to be posted in the LinkedIn.

“Post a Image”

Visibility

In this section you need to mention the visibility criteria of the posted content. That means you need to select who can visit your content. It can be public, connections, or specific group member.

“Public “