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.
- Client Login
- /oauth/Authorization
- Redirect to login/authorization prompt
- Authenticate and consent
- Authorization Code
- Authorization code/ClientId/Scope
- Access token
- Api calls with the access token
- 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".
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.
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.
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.
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
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
Step 5. Power Automate flow.
Integrate the custom connector into the scheduled flow.
Analyze the output of the connector and retrieve the necessary fields to integrate into a SharePoint list.