In this blog, I would like to show you the steps to publish a CMP (Content Marketing Platform) content with an associated asset from Sitecore Content Hub (4.x) to LinkedIn social media platform.
Step 1: Create an LinkedIn OAuth2 access token
Follow the instructions found in this page https://docs.microsoft.com/en-us/linkedin/shared/authentication/authorization-code-flow?context=linkedin%2Fcontext&tabs=HTTPS to create an OAuth2 token.
For this example, I've selected "r_liteprofile%20r_emailaddress%20w_member_social" as the scope for my application created in the LinkedIn Developer Portal. Actually, you cannot select the scope directly but rather through the Products available for selection - "Shared on LinkedIn, Sign in with LinkedIn" as shown in the screenshot below.
Make a note or copy this OAuth token in a secure place as you would need it in the subsequent steps below. If you lose it, you'd have to go through the steps again to generate another one.
Tip: For quick and hassle free setup, I've used Postman.
Step 1a: Make an Postman API call to https://api.linkedin.com/v2/me with the OAuth token generated above in Postman or any other tool and copy the "id" value returned in the JSON result.
Step 2: Setup Azure Service Bus, storage account
Setup an Azure Service Bus and create a topic inside with the following details:
Topic Name: linkedin
Subscription Name: sch
Create an Azure Storage account for the Azure Function described in Step 4 below.
Step 3: Setup Sitecore Content Hub
Setup a Sitecore Content Hub sandbox with version 4 and above (preferably in the latest version 4.1) with CMP, DAM selected as features.
- Setup an Azure Service Bus action that points to the Service Bus connection string created above
- Setup an trigger with "Entity modification" objective and "In background" execution type with the following conditions as in the screenshot
- Setup OAuth token in Content Hub and copy the ClientId and ClientSecret in a secured place
- Setup an API user with Superuser privileges, note down the password
Step 4: Setup Azure Function as an integration layer between Content Hub and LinkedIn
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "azure storage account connection storage string",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"ServiceBusConnection": "azure service bus connection string>"
}
}
- MHost - Appropriate value of your Content Hub instance (ex: https://xxxx.stylelabs.io)
- MClientId - Content Hub OAuth Client Id setup in Step 3 above
- MClientSecret - Content Hub OAuth Client Secret
- MUsername - Content Hub API username
- MPassword - Content Hub API user password
- LinkedInPersonId - Person Id value from Step 1 above
- LinkedInOAuthToken - OAuth token value from Step 1 above
- ServiceBusConnection - Copy the Azure Service Bus connection string
- AzureWebJobsStorage - Copy the Azure Storage account connection string
Comments
Post a Comment