Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

2.6 KB
Raw Blame
import {
  OAuth2PropertyValue,
  PieceAuth,
  createPiece,
} from '@activepieces/pieces-framework';

import { PieceCategory } from '@activepieces/pieces-framework';
import { createCompanyUpdate } from './lib/actions/create-company-update';
import { createShareUpdate } from './lib/actions/create-share-update';
import { createCustomApiCallAction } from '@activepieces/pieces-common';
import { linkedinCommon } from './lib/common';
import { createMemberPost } from './lib/actions/create-member-post';
import { getCurrentMemberProfile } from './lib/actions/get-current-member-profile';
import { listManagedOrganizations } from './lib/actions/list-managed-organizations';
import { updatePostCommentary } from './lib/actions/update-post-commentary';
import { deletePost } from './lib/actions/delete-post';
import { createImageUploadUrl } from './lib/actions/create-image-upload-url';

export const linkedinAuth = PieceAuth.OAuth2({
  description:
    'Sign in with the LinkedIn account that should publish the posts. To post on a Company Page, that account must be one of its admins.',
  authUrl: 'https://www.linkedin.com/oauth/v2/authorization',
  tokenUrl: 'https://www.linkedin.com/oauth/v2/accessToken',
  required: true,
  scope: [
    'w_member_social',
    'w_organization_social',
    'rw_organization_admin',
    'openid',
    'email',
    'profile',
  ],
});

export const linkedin = createPiece({
  displayName: 'LinkedIn',
  description: 'Post to LinkedIn profiles and Company Pages',

  minimumSupportedRelease: '0.88.2',
  logoUrl: 'https://cdn.activepieces.com/pieces/linkedin.png',
  categories: [PieceCategory.MARKETING],
  authors: ["aasimsani","kishanprmr","MoShizzle","khaledmashaly","abuaboud", "izdrail"],
  auth: linkedinAuth,
  actions: [
    createShareUpdate,
    createCompanyUpdate,
    getCurrentMemberProfile,
    listManagedOrganizations,
    createMemberPost,
    updatePostCommentary,
    deletePost,
    createImageUploadUrl,
    createCustomApiCallAction({
      auth: linkedinAuth,
      baseUrl: () => {
        return linkedinCommon.baseUrl;
      },
      authMapping: async (auth) => {
        return {
          Authorization: `Bearer ${(auth as OAuth2PropertyValue).access_token}`,
        };
      },
      props: {
        url: {
          description: `Full URL, or a path relative to ${linkedinCommon.baseUrl}`,
          placeholder: '/v2/userinfo',
        },
        headers: {
          description: `Calls to /rest/ need LinkedIn-Version: ${linkedinCommon.linkedinHeaders['LinkedIn-Version']} and X-Restli-Protocol-Version: 2.0.0. Authorization comes from your connection.`,
        },
      },
    }),
  ],
  triggers: [],
});