CLI tool for posting to LinkedIn and checking engagement.
- Go to https://www.linkedin.com/developers/
- Create a new app (you'll need to associate it with a LinkedIn Company Page — you can create a throwaway one)
- Under Products, request access to:
- Share on LinkedIn (grants
w_member_socialscope — for posting) - Sign In with LinkedIn using OpenID Connect (grants
openid,profile,email— for getting your person ID)
- Share on LinkedIn (grants
- Under Auth settings, add
http://localhost:3457/callbackas an Authorized redirect URL - Copy your Client ID and Client Secret
cp .env.example .env
# Edit .env with your Client ID and Client Secretlinkedin auth # Opens browser for OAuth flow
# Automatically saves access token, refresh token, and person ID# Auth
linkedin auth # OAuth login flow
linkedin auth status # Check if token is valid
linkedin auth refresh # Refresh an expired token
# Profile
linkedin profile # Show your profile info
linkedin profile --save # Show profile and save person ID to .env
# Posts
linkedin posts create --text "Hello LinkedIn!" # Text post
linkedin posts create --text "Check this out" --link "https://..." # Post with link preview
linkedin posts create --text "New photo" --image ./photo.jpg # Post with image
linkedin posts create --text "..." --visibility connections # Connections-only post
linkedin posts list # List your recent posts
linkedin posts list -n 20 # List more posts
linkedin posts get <post-urn> # Get post details + engagement stats
linkedin posts delete <post-urn> # Delete a post- Access tokens expire in 60 days
- Refresh tokens expire in 365 days
- Run
linkedin auth statusto check validity - Run
linkedin auth refreshto refresh without re-authenticating
npm run dev -- posts list # Run from TypeScript directly
npm run build # Compile to dist/