Tech Tip: Adding a private GitHub Component to your 4D project
PRODUCT: 4D | VERSION: 20 R | PLATFORM: Mac & Win
Published On: May 20, 2025
Integrating private components from GitHub into your 4D project is straightforward using the 4D Dependency Manager with secure authentication via a Personal Access Token (PAT). Follow these steps to add your private component safely and efficiently:
- Generate a GitHub Personal Access Token (PAT)
- Log into your GitHub account.
- Navigate to your profile icon → Settings → Developer settings → Personal access tokens → Tokens (classic).
- Click Generate new token (classic).
- Give your token a descriptive name, e.g., `4D Project Access`.
- Select the required scopes — for private repositories, repo scope is essential.
- Generate the token and copy it immediately. (You won’t see it again.)
- Add the Private Component in Your 4D Project
- Open your 4D project in the 4D.
- Navigate to Design → Project Dependencies.
- Click Add Component (usually a "+" button).
- Paste the GitHub repository URL of your private component (e.g., "https://github.com/username/private-component").
- Click "Add a personal access token", enter your GitHub Personal Access Token. This authenticates 4D to access your private repo securely.
- Confirm the addition.
Best Practices:
- Secure your PAT: Never hardcode your token in project files or share it publicly.
- Least privilege: Only grant the minimum permissions required to the token (usually just `repo` access).
- Keep tokens up-to-date: Regenerate tokens periodically and revoke unused ones.
- Version control: Use tags or branches to lock component versions if needed.