Using LinkedIn API in Power Automate

Context

The purpose of this project is to collect posts published on a LinkedIn page into a SharePoint list

Prerequisites

A premium Power Automate license (per app/user) is required to use custom connectors.

Development

The diagram below shows the process flow.

  1. Client Login
  2. /oauth/Authorization
  3. Redirect to login/authorization prompt
  4. Authenticate and consent
  5. Authorization Code
  6. Authorization code/ClientId/Scope
  7. Access token
  8. Api calls with the access token
  9. Api response

LinkedIn API Request

Create your LinkedIn application from this URL (LinkedIn developer: https://developer.linkedin.com/) and enter the URL of the LinkedIn page, for example: https://www.linkedin.com/company/{OrganizationId}.

Click on "Create".

Create

Creating a LinkedIn application allows you to obtain the client ID and client secret of the application. To use LinkedIn APIs, you need to request permissions to assign to the application. In our case, we want to collect posts from a LinkedIn page.

Request Permissions

We need two scopes: r_organization_social and r_member_social. In the products section, we have a list of all products and their endpoints. Simply request access through a form that LinkedIn must approve. Once done, the product becomes available and you can see that the permissions have been added in the Auth tab of the application.

OAuth 2.0 scopes

Custom connector

creating a custom connector to use the LinkedIn API in Power Automate. Here are the steps you need to follow:

Step 1. First, in the general section, you need to define the host to be used for your LinkedIn API, which is api.linkedin.com.

Step 2. Next, in the Security section, you need to select the authentication type as Oauth2.0 and the identity provider as Generic Oauth 2. You also need to enter the clientID and client secret of the LinkedIn application that you have created. Finally, you need to provide the Authorization URL (https://www.linkedin.com/oauth/v2/authorization) and Token URL (https://www.linkedin.com/oauth/v2/accessToken) for authentication.

Security

Save the connector to obtain the redirection URL https://global.consent.azure-apim.net/redirect. Copy the redirection URL and add it to the authorized redirect URLs on the LinkedIn app

Auth

Step 3. Definition section: Add the request that we will use GET https://api.linkedin.com/v2/posts?author=urn%3Ali%3Aorganization%3A{IdOrg}

You need to define the following headers: Content-type: application/json LinkedIn-Version: 202301

Step 4. Create the connector and establish the connection

Create connector

Step 5. Power Automate flow.

 Integrate the custom connector into the scheduled flow.

Scheduled flow

Analyze the output of the connector and retrieve the necessary fields to integrate into a SharePoint list.

Analyzer JSON

Condition


Similar Articles