# LinkedIn Environment Variables Template

**⚠️ Important Note (2024):** LinkedIn API has significant limitations. You can only access the authenticated user's own profile, not other users' profiles.

Copy these variables to your `.env` file and fill in your actual LinkedIn API credentials.

## Required Variables

```env
# LinkedIn API Configuration
LINKEDIN_CLIENT_ID=your_linkedin_client_id_here
LINKEDIN_CLIENT_SECRET=your_linkedin_client_secret_here
LINKEDIN_REDIRECT_URI=https://yourdomain.com/linkedin/callback
LINKEDIN_API_VERSION=v2
```

## Optional Variables

```env
# LinkedIn Access Token (for development/testing only)
# In production, use OAuth flow instead
# Note: This will only work for the user who generated the token
LINKEDIN_ACCESS_TOKEN=your_linkedin_access_token_here
```

## Example Configuration

```env
# LinkedIn API Configuration
LINKEDIN_CLIENT_ID=86abc123def456ghi789
LINKEDIN_CLIENT_SECRET=ABC123def456GHI789jkl012MNO345pqr678stu901vwx234yz
LINKEDIN_REDIRECT_URI=https://mycrm.com/linkedin/callback
LINKEDIN_API_VERSION=v2
```

## How to Get These Values

1. **LINKEDIN_CLIENT_ID**: Found in your LinkedIn App's "Auth" tab
2. **LINKEDIN_CLIENT_SECRET**: Found in your LinkedIn App's "Auth" tab
3. **LINKEDIN_REDIRECT_URI**: Your application's callback URL for OAuth
4. **LINKEDIN_API_VERSION**: Usually "v2" (default)

## Current API Limitations

### ✅ **What Works:**
- **User Authentication**: OAuth sign-in with LinkedIn
- **Own Profile**: Access to authenticated user's basic profile
- **Email Permission**: If user grants access
- **Current Position**: Limited company and job title info

### ❌ **What Doesn't Work:**
- **Other Users' Profiles**: Cannot fetch data from LinkedIn URLs
- **Contact Information**: No phone numbers, addresses
- **Extended Data**: No work history, education, etc.
- **Network Access**: Cannot see connections or network

## Security Notes

- **Never commit** your `.env` file to version control
- **Keep your client secret** secure and private
- **Use OAuth flow** in production instead of hardcoded access tokens
- **Rotate credentials** regularly for security
- **Understand limitations** - this is not a full LinkedIn data extraction tool

## Testing Your Configuration

After setting up your environment variables, test the connection:

```bash
# Test LinkedIn API connection
curl http://yourdomain.com/linkedin/test

# Check LinkedIn API status
curl http://yourdomain.com/linkedin/status
```

## Expected Behavior

With the current LinkedIn API limitations:

1. **LinkedIn URL Validation**: Will validate URL format
2. **Mock Data Generation**: Will generate realistic demo data
3. **Real API Access**: Only works for authenticated user's own profile
4. **Contact Creation**: Primarily manual data entry with LinkedIn URL reference

## Troubleshooting

If you encounter issues:

1. **Check your credentials** are correct
2. **Verify redirect URI** matches exactly what's in LinkedIn App
3. **Ensure OAuth scopes** are properly configured (`r_liteprofile r_emailaddress`)
4. **Check API permissions** are approved by LinkedIn
5. **Review error logs** for detailed information
6. **Understand limitations** - many features are no longer available

## Alternative Solutions

Since LinkedIn API cannot fetch other users' data, consider:

1. **Manual Contact Entry**: Primary method for contact creation
2. **CSV Import**: Bulk contact import from spreadsheets
3. **Email Integration**: Extract contact info from email signatures
4. **Business Card Scanning**: OCR-based contact extraction
5. **Social Media Integration**: Other platforms with better API access

## Support

For LinkedIn API support:
- [LinkedIn API Documentation](https://developer.linkedin.com/docs)
- [LinkedIn Developer Community](https://developer.linkedin.com/community)
- [LinkedIn API Status](https://developer.linkedin.com/status)

**Note:** Many community resources may reference outdated API features that are no longer available.
