This guide explains how to create and configure GitHub tokens for ActionsGuard.
ActionsGuard uses the GitHub API to:
- Fetch repository information
- Read workflow files from
.github/workflows/ - List repositories in organizations
- Access repository metadata
If you're scanning private repositories, you MUST have the correct token permissions:
| Repository Type | Required Permission (Classic) | Required Permission (Fine-grained) |
|---|---|---|
| Private repos | repo scope |
Contents: Read + Metadata: Read |
| Public repos only | public_repo scope |
Public Repositories (read-only) |
Common Issue: If you see "0 repositories found" when scanning your own account, your token likely only has public_repo scope but your repos are private. Solution: Create a new token with repo scope.
Quick Fix for Private Repos:
# 1. Create a new classic token at: https://github.com/settings/tokens/new
# 2. Check the 'repo' box (full control of private repositories)
# 3. Generate and copy the token
# 4. Set it:
export GITHUB_TOKEN='ghp_your_new_token_here'
# 5. Test it:
actionsguard debug --user your-usernameAdvantages:
- ✅ More secure - limited to specific repositories
- ✅ Granular permissions - only what's needed
- ✅ Automatic expiration (forces regular rotation)
- ✅ Audit log for token usage
- ✅ Can be restricted by IP address
- ✅ GitHub's recommended approach
Disadvantages:
- Slightly more complex to set up
- Need to update when adding new repositories
Advantages:
- ✅ Simple to set up
- ✅ Works across all accessible repositories
Disadvantages:
- ❌ Broader access than needed
- ❌ No automatic expiration
- ❌ Less secure
Go to: https://github.com/settings/personal-access-tokens/new
- Token name:
ActionsGuard Scanner - Expiration: 90 days (recommended) or custom
- Description:
Security scanning for GitHub Actions workflows
Choose based on your use case:
For Single Repository Scanning:
- Select: "Only select repositories"
- Click "Select repositories" and choose the repos you want to scan
For Organization Scanning:
- Select: "All repositories"
- This gives access to all repos in organizations you're a member of
For Public Repository Scanning Only:
- Select: "Public Repositories (read-only)"
- No additional permissions needed
Set these permissions:
| Permission | Access Level | Purpose |
|---|---|---|
| Actions | Read | Access workflow files in .github/workflows/ |
| Contents | Read | Read repository files and structure |
| Metadata | Read | Access basic repository information (automatic) |
Only needed for organization scanning:
| Permission | Access Level | Purpose |
|---|---|---|
| Members | Read | List repositories in the organization |
- Click "Generate token"
- Copy the token immediately - it starts with
github_pat_ - Store it securely (password manager recommended)
Go to: https://github.com/settings/tokens/new
- Note:
ActionsGuard Scanner - Expiration: 90 days (recommended)
For Private Repository Scanning:
- ✅
repo- Full control of private repositories- Includes:
repo:status,repo_deployment,public_repo,repo:invite,security_events
- Includes:
For Public Repository Scanning Only:
- ✅
public_repo- Access public repositories only
For Organization Scanning:
- ✅
read:org- Read org and team membership, read org projects
- Click "Generate token"
- Copy the token immediately - it starts with
ghp_ - Store it securely
# Set for current session
export GITHUB_TOKEN="your_token_here"
# Make it permanent (choose your shell)
# For Zsh (default on macOS):
echo 'export GITHUB_TOKEN="your_token_here"' >> ~/.zshrc
source ~/.zshrc
# For Bash:
echo 'export GITHUB_TOKEN="your_token_here"' >> ~/.bashrc
source ~/.bashrcPowerShell:
# Set for current session
$env:GITHUB_TOKEN = "your_token_here"
# Make it permanent
[System.Environment]::SetEnvironmentVariable('GITHUB_TOKEN', 'your_token_here', 'User')Command Prompt:
set GITHUB_TOKEN=your_token_hereGitHub Actions:
- name: Run ActionsGuard
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: actionsguard scan --org my-orgGitLab CI:
variables:
GITHUB_TOKEN: $GITHUB_TOKEN # Set in CI/CD settings# Should display your token (be careful in shared terminals!)
echo $GITHUB_TOKEN
# Check if it's set (without displaying)
[ -z "$GITHUB_TOKEN" ] && echo "Token not set" || echo "Token is set"# Should return your GitHub username
curl -H "Authorization: token $GITHUB_TOKEN" \
https://api.github.com/user | jq '.login'
# Check rate limits
curl -H "Authorization: token $GITHUB_TOKEN" \
https://api.github.com/rate_limit | jq '.rate'# List accessible repositories
curl -H "Authorization: token $GITHUB_TOKEN" \
https://api.github.com/user/repos | jq '.[].full_name'
# Test org access
curl -H "Authorization: token $GITHUB_TOKEN" \
https://api.github.com/user/orgs | jq '.[].login'- Use Fine-grained Tokens: More secure and auditable
- Set Expiration: Force regular token rotation
- Minimum Permissions: Only grant what's needed
- Secure Storage: Use environment variables or secret managers
- Never Commit Tokens: Add to
.gitignore - Rotate Regularly: Create new tokens every 90 days
- Revoke Unused Tokens: Clean up at https://github.com/settings/tokens
- Monitor Usage: Check audit logs for suspicious activity
Error: 401 Unauthorized - Bad credentialsSolutions:
- Token may be expired or revoked
- Token may not be set correctly
- Verify with:
echo $GITHUB_TOKEN - Create a new token
Error: 404 Not FoundSolutions:
- Organization name may be incorrect
- You may not be a member of the organization
- For fine-grained tokens: Check "Members: Read" permission
- For classic tokens: Verify
read:orgscope
Error: API rate limit exceededSolutions:
- Authenticated requests: 5,000/hour
- Unauthenticated: 60/hour
- Check reset time:
curl -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/rate_limit - Wait for reset or use different token
Error: Repository not found or access deniedSolutions:
- For fine-grained: Add repository to "Repository access"
- For classic: Ensure
reposcope (not justpublic_repo) - Verify you have access to the repository
When tokens expire or need rotation:
- Create new token with same permissions
- Test new token:
GITHUB_TOKEN=new_token actionsguard --version - Update environment variable
- Revoke old token
- Update CI/CD secrets
Fine-grained tokens: https://github.com/settings/personal-access-tokens
Classic tokens: https://github.com/settings/tokens
Click "Delete" next to the token you want to revoke.
See the main README.md or QUICKSTART.md for more information.