Skip to content

gxbvc/linkedin-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

linkedin

CLI tool for posting to LinkedIn and checking engagement.

Setup

1. Create a LinkedIn App

  1. Go to https://www.linkedin.com/developers/
  2. Create a new app (you'll need to associate it with a LinkedIn Company Page — you can create a throwaway one)
  3. Under Products, request access to:
    • Share on LinkedIn (grants w_member_social scope — for posting)
    • Sign In with LinkedIn using OpenID Connect (grants openid, profile, email — for getting your person ID)
  4. Under Auth settings, add http://localhost:3457/callback as an Authorized redirect URL
  5. Copy your Client ID and Client Secret

2. Configure credentials

cp .env.example .env
# Edit .env with your Client ID and Client Secret

3. Authenticate

linkedin auth              # Opens browser for OAuth flow
                           # Automatically saves access token, refresh token, and person ID

Usage

# 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

Token Expiration

  • Access tokens expire in 60 days
  • Refresh tokens expire in 365 days
  • Run linkedin auth status to check validity
  • Run linkedin auth refresh to refresh without re-authenticating

Development

npm run dev -- posts list              # Run from TypeScript directly
npm run build                          # Compile to dist/

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors