Get your dream built 10x faster

How to integrate LinkedIn API with OpenClaw

We build custom applications 5x faster and cheaper 🚀

Book a Free Consultation
4.9
Clutch rating 🌟
600+
Happy partners
17+
Countries served
190+
Team members
Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Stuck on an error? Book a 30-minute call with an engineer and get a direct fix + next steps. No pressure, no commitment.

How to integrate LinkedIn API with OpenClaw

Direct answer: Build a LinkedIn integration as a standard OAuth 2.0 + REST connector: register a LinkedIn app to get client_id/secret and the right scopes (w_member_social for user posts, w_organization_social + rw_organization\_admin for organization posts), implement the OAuth Authorization Code flow to obtain access tokens, store tokens securely outside the agent (secrets/DB), implement backend endpoints (authorization callback, optional webhook receiver, token refresh/re-auth), and implement a ClawHub-installed OpenClaw skill that calls LinkedIn’s REST APIs (e.g., /v2/me, /v2/ugcPosts) with Bearer tokens. Keep stateful pieces (token storage, schedulers, webhook receivers) outside the agent runtime; configure the skill in ClawHub with secrets and environment variables so the skill code can call LinkedIn’s API authenticated. Debug by inspecting LinkedIn JSON responses, HTTP status codes and headers, token expiry/scopes, and your service logs.

 

What you need first

 
  • LinkedIn developer app: Create an app at LinkedIn’s developer portal and set a Redirect URI your auth callback will use. Record client_id and client_secret.
  • Decide capabilities and scopes: For posting as a member use w_member_social. For organization posting you will need w_organization_social and the account must have org admin privileges (and typically rw_organization_admin to manage org permissions). Add r\_liteprofile if you need the member urn.
  • Public callback endpoint: OAuth requires a reachable redirect URI — this must be hosted outside the agent runtime (a web server or serverless function).
  • Secrets store: Plan where tokens and client secrets live (secret manager, database, or ClawHub secret configuration). Do not rely on ephemeral agent memory for long-term storage.

 

High-level architecture (recommended)

 
  • Auth & token handling (external service): A small web service handles the OAuth authorization flow, token exchange, token persistence, and token refresh/re-auth as needed. This service owns the redirect URI.
  • Webhook receiver (optional): If you subscribe to LinkedIn change notifications, run a public webhook receiver externally that validates LinkedIn’s challenge/signature per LinkedIn docs and forwards events to your processing layer.
  • Skill code (OpenClaw): The OpenClaw skill is the connector layer that runs inside the agent: it is responsible for calling LinkedIn REST endpoints using stored tokens. Keep the skill stateless: read tokens from the configured secret store at invocation time.
  • Background jobs and scheduling: Run scheduled jobs (e.g., queued posts, retries) outside the agent in a scheduler/worker. The agent can be invoked to perform single actions but don’t rely on the agent for long-running scheduled processing.

 

Detailed steps to implement

 
  • 1) Register LinkedIn app
    • Enter a valid redirect URI (must be reachable publicly).
    • Note the client_id and client_secret; store them in your secret manager or ClawHub secret configuration.
  • 2) Implement OAuth Authorization Code flow (backend)
    • Construct an authorization URL and direct the user there so they can grant scopes. Example URL format:
      https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id=YOUR_CLIENT_ID&redirect_uri=YOUR_REDIRECT_URI&scope=w_member_social%20r_liteprofile&state=RANDOM
    • After the user consents, LinkedIn redirects back with code. Exchange this code for an access token by POSTing to LinkedIn’s token endpoint (server-side):
      curl -X POST "https://www.linkedin.com/oauth/v2/accessToken" \ 
      -H "Content-Type: application/x-www-form-urlencoded" \ 
      -d "grant_type=authorization_code&code=AUTH_CODE&redirect_uri=YOUR_REDIRECT_URI&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET"
    • Store the returned access token (and refresh token if provided by LinkedIn) securely. Record the expiry time so you can refresh or re-auth before it expires.
  • 3) Retrieve actor URN (member or organization)
    • To post as a member, get the member URN with:
      curl -H "Authorization: Bearer ACCESS\_TOKEN" \ 
      https://api.linkedin.com/v2/me
      This returns JSON including the member URN (format: urn:li:person:{id}).
    • To post as an organization, you’ll need the organization URN. Confirm the authenticated account is an admin of the organization (the app must be granted org permissions). You can fetch or list organizations using LinkedIn APIs when you have the correct scopes/permissions.
  • 4) Post content (example: UGC post for a member)
    • Use the UGC endpoint to create rich posts. Required headers include Authorization and LinkedIn protocol version. Example:
      curl -X POST "https://api.linkedin.com/v2/ugcPosts" \\
      -H "Authorization: Bearer ACCESS\_TOKEN" \\
      -H "X-Restli-Protocol-Version: 2.0.0" \\
      -H "Content-Type: application/json" \\
      -d '{
        "author":"urn:li:person:PERSON\_ID",
        "lifecycleState":"PUBLISHED",
        "specificContent":{
          "com.linkedin.ugc.ShareContent":{
            "shareCommentary":{"text":"Hello from OpenClaw integration"},
            "shareMediaCategory":"NONE"
          }
        },
        "visibility":{"com.linkedin.ugc.MemberNetworkVisibility":"CONNECTIONS"}
      }'
    • For org posts, set "author":"urn:li:organization:ORG\_ID" and ensure you have the organization scopes and admin status.
  • 5) Configure the OpenClaw skill via ClawHub
    • Install the skill package in ClawHub and provide the skill with required environment variables/secrets: client_id, client_secret (if the skill must perform token exchange), or better, a reference to your external token store and an API key to fetch tokens at runtime.
    • Store only the minimal secret material in ClawHub’s secure config (never plaintext tokens in code). The skill should retrieve the current access token at invocation time from the external store.
    • Ensure the skill invocation has permission to read secrets or call your token service (use scoped service accounts or short-lived credentials).
  • 6) Token lifecycle
    • Track token expiry. If LinkedIn provides a refresh token, implement a refresh flow server-side; if not, trigger a re-auth flow when the token expires.
    • Avoid relying on the agent for refreshing. Do the refresh in the external service and update the secret store used by the skill.

 

Operational and security considerations

 
  • Least privilege: Request only the scopes you truly need. A scope like w_member_social gives posting capability — don’t over-request read/write org scopes unless necessary.
  • Store secrets securely: Use a secrets manager or ClawHub’s secure secret mechanism to store client_secret and tokens. Rotate client_secret if exposed.
  • Webhook validation: If you use LinkedIn webhooks (change notifications), implement the verification challenge and signature validation per LinkedIn docs. Host the receiver publicly and forward validated events to your internal processing pipeline.
  • Rate limits and retry strategy: Inspect LinkedIn’s response headers for rate-limit info. Implement exponential backoff on 429 responses and surface 401/403 responses for re-auth or scope fixes.
  • Don’t rely on the agent for persistence or scheduling: The OpenClaw agent is the runtime to execute a skill. Keep persistent state and job scheduling outside so restarts or agent scale don’t break continuity.

 

Debugging checklist

 
  • Inspect HTTP status codes and JSON error payloads returned by LinkedIn (they usually include a descriptive error field).
  • Confirm the access token being used matches the intended account and has not expired.
  • Validate scopes granted in the token match required operations (403 often means missing scope or insufficient org admin rights).
  • For organization actions, confirm the account is an administrator of the organization via LinkedIn admin endpoints.
  • Log request/response bodies and headers (secure logs: strip tokens when exporting). Look for X-Restli headers for additional LinkedIn diagnostics.

 

Minimal example flows (curl)

 
  • Authorization URL (open in user browser):
    https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id=YOUR_CLIENT_ID&redirect_uri=YOUR_REDIRECT_URI&scope=w_member_social%20r_liteprofile&state=RANDOM
  • Exchange code for access token:
    curl -X POST "https://www.linkedin.com/oauth/v2/accessToken" \\
    -H "Content-Type: application/x-www-form-urlencoded" \\
    -d "grant_type=authorization_code&code=AUTH_CODE&redirect_uri=YOUR_REDIRECT_URI&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET"
  • Get authenticated member URN:
    curl -H "Authorization: Bearer ACCESS\_TOKEN" \\
    https://api.linkedin.com/v2/me
  • Create a simple UGC post (member):
    curl -X POST "https://api.linkedin.com/v2/ugcPosts" \\
    -H "Authorization: Bearer ACCESS\_TOKEN" \\
    -H "X-Restli-Protocol-Version: 2.0.0" \\
    -H "Content-Type: application/json" \\
    -d '{
      "author":"urn:li:person:PERSON\_ID",
      "lifecycleState":"PUBLISHED",
      "specificContent":{
        "com.linkedin.ugc.ShareContent":{
          "shareCommentary":{"text":"Hello from an OpenClaw skill"},
          "shareMediaCategory":"NONE"
        }
      },
      "visibility":{"com.linkedin.ugc.MemberNetworkVisibility":"CONNECTIONS"}
    }'

Book Your Free 30‑Minute Migration Call

Speak one‑on‑one with a senior engineer about your no‑code app, migration goals, and budget. In just half an hour you’ll leave with clear, actionable next steps—no strings attached.

Book a Free Consultation

Troubleshooting LinkedIn API and OpenClaw Integration

1

LinkedIn OAuth2 token refresh fail

Short answer: A LinkedIn OAuth2 refresh fails because the refresh token, client credentials, endpoint, or scopes are wrong, the token was revoked/expired, or your code mis-parses the response — fix by verifying the exact error, confirming client_id/secret and token endpoint, securely persisting the refresh token, and retrying with correct parameters.

 

Troubleshoot and fix

 
  • Inspect the error body: log HTTP status and JSON error_description from LinkedIn.
  • Verify request: POST to the provider token endpoint with grant_type=refresh_token, client_id, client_secret, refresh_token.
  • Check token lifecycle: LinkedIn may rotate or revoke refresh tokens — ensure you store new refresh_token from responses.
  • Secure storage: keep tokens in env vars or vault and ensure agent skill has permission to read them.
// Node.js fetch example
const res = await fetch(process.env.TOKEN_URL, {
  method:'POST',
  headers:{'Content-Type':'application/x-www-form-urlencoded'},
  body:new URLSearchParams({
    grant_type:'refresh_token',
    client_id:process.env.CLIENT_ID,
    client_secret:process.env.CLIENT_SECRET,
    refresh_token:process.env.REFRESH_TOKEN
  })
});
const body = await res.json(); // log body for errors

2

LinkedIn scopes redirect URI OpenClaw Secret Store

Direct answer: Request LinkedIn scopes you need (commonly r_liteprofile, r_emailaddress, and w_member_social for posting), register an exact redirect URI in the LinkedIn app that points to your OpenClaw agent callback (HTTPS, exact path and query), and put CLIENT_ID and CLIENT_SECRET in the OpenClaw Secret Store as environment variables referenced by your skill. Validate state and store refresh/access tokens outside the runtime.

 

Details

 
  • Scopes: choose minimal scopes required.
  • Redirect URI: register exact HTTPS callback (no wildcards).
  • Secrets: save client_secret in OpenClaw Secret Store and reference via env vars in skill configuration.
  • Security: validate state, use server-side token storage (DB) not ephemeral runtime.
// build auth URL inside skill (Node)
const url = `https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id=${process.env.LINKEDIN_CLIENT_ID}&redirect_uri=${encodeURIComponent(process.env.LINKEDIN_REDIRECT)}&scope=r_liteprofile%20r_emailaddress%20w_member_social&state=${state}`
// exchange code using CLIENT_SECRET from env

3

LinkedIn profile company incomplete pagination

Direct answer: Incomplete LinkedIn company lists usually come from not iterating the API's pagination (start/count or cursor) or lacking required permissions; fix by reading the response's paging object and repeatedly requesting until no more elements, handling rate limits and auth.

 

Common causes

 
  • Using default limits (only first page returned).
  • Not using start/count or cursor from the response.
  • Insufficient scopes or private data hidden.

 

How to fix

 
  • Read paging (start,count,total) and loop: request start+=count until elements empty.
  • Respect rate limits and OAuth scopes.
  • Log each response to confirm progression and stop on errors.

4

LinkedIn webhook signature verification HMAC secret

Verify by computing an HMAC-SHA256 over the raw request body using your LinkedIn webhook secret (store it as an environment variable), then compare that digest to the signature header LinkedIn sends using a constant-time comparison; also validate any timestamp to prevent replay attacks.

 

How to verify

 

Steps

  • Keep the secret in an env var (e.g. LINKEDIN_WEBHOOK_SECRET).
  • Compute HMAC-SHA256 of the raw request body, encode as base64 (or as LinkedIn specifies).
  • Compare to the signature header with a timing-safe compare; check timestamps.
// Node.js Express example; req.rawBody must contain raw bytes
const crypto = require('crypto');
const secret = process.env.LINKEDIN_WEBHOOK_SECRET;
function verify(req){
  const sig = req.headers['x-li-signature']; // replace with exact header per docs
  const h = crypto.createHmac('sha256', secret).update(req.rawBody).digest('base64');
  return crypto.timingSafeEqual(Buffer.from(h), Buffer.from(sig));
}
Book a Free Consultation

Still stuck?
Copy this prompt into ChatGPT and get a clear, personalized explanation.

This prompt helps an AI assistant understand your setup and guide you through the fix step by step, without assuming technical knowledge.

AI AI Prompt


Recognized by the best

Trusted by 600+ businesses globally

From startups to enterprises and everything in between, see for yourself our incredible impact.

RapidDev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with.

They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

Arkady
CPO, Praction
Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost.

He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Donald Muir
Co-Founder, Arc
RapidDev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space.

They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Mat Westergreen-Thorne
Co-CEO, Grantify
RapidDev is an excellent developer for custom-code solutions.

We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Emmanuel Brown
Co-Founder, Church Real Estate Marketplace
Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 

This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Samantha Fekete
Production Manager, Media Production Company
The pSEO strategy executed by RapidDev is clearly driving meaningful results.

Working with RapidDev has delivered measurable, year-over-year growth. Comparing the same period, clicks increased by 129%, impressions grew by 196%, and average position improved by 14.6%. Most importantly, qualified contact form submissions rose 350%, excluding spam.

Appreciation as well to Matt Graham for championing the collaboration!

Michael W. Hammond
Principal Owner, OCD Tech

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We’ll discuss your project and provide a custom quote at no cost.Â