Authentication Methods
Codemod supports three authentication methods for publishing:| Method | Best For | Secrets Required | Setup |
|---|---|---|---|
| Interactive Login | Local development | None | None |
| API Keys | CI/CD pipelines, automation | Yes (CODEMOD_API_KEY) | Create key in UI |
| Trusted Publishers | GitHub Actions, secure CI/CD | None (uses OIDC) | None for org scopes* |
Interactive Login
The simplest way to authenticate for local development. Opens a browser for OAuth authentication.When to Use
- Local development and testing
- Quick one-off publishes
- When you prefer browser-based authentication
API Keys
API keys allow non-interactive authentication, perfect for CI/CD pipelines and automation.Creating an API Key
- Go to codemod.com/api-keys
- Click Create API Key
- Give it a descriptive name (e.g., “GitHub Actions - my-repo”)
- Select the permissions (typically “Publish Packages”)
- Copy the key (it won’t be shown again)
Using API Keys
Option 1: Login with API keyGitHub Actions Example
When to Use
- CI/CD pipelines without GitHub Actions OIDC
- GitLab CI, CircleCI, Jenkins, etc.
- Automated publishing from any environment
- When you need explicit control over credentials
Trusted Publishers
Trusted publishers enable passwordless publishing from GitHub Actions using OpenID Connect (OIDC). No secrets to manage or rotate.How OIDC Works
GitHub Actions can request short-lived tokens that cryptographically prove the workflow’s identity. Codemod verifies these tokens against your configured trusted publishers.
Benefits
- No secrets to manage – No API keys to create, rotate, or accidentally leak
- Cryptographically secure – Tokens are signed by GitHub and verified by Codemod
- Fine-grained control – Restrict by repository, workflow, environment, or git ref
- Short-lived tokens – Tokens expire in ~5 minutes, limiting exposure
Organization Scopes (Zero Configuration)
This is the recommended approach for organizations. If your GitHub organization name matches your package scope, trusted publishing works automatically with no UI configuration needed.
@my-org/my-codemod), trusted publishers work automatically when:
- Your GitHub organization name matches the package scope (e.g., GitHub org
my-org→ scope@my-org) - You’ve linked your GitHub organization to your Codemod organization
acme-corp and you’ve linked it to your Codemod organization with scope @acme-corp:
@acme-corp/any-codemod from any repository in the acme-corp GitHub organization.
Individual Packages (Manual Configuration)
For packages that don’t match an organization scope (unscoped packages or packages where the GitHub org doesn’t match), you need to configure a trusted publisher manually:1
Configure Trusted Publisher in UI
- Go to codemod.com/api-keys
- Scroll to Trusted Publishers
- Click Add Trusted Publisher
- Select your package and enter the GitHub repository details
- (Optional) Add restrictions for extra security
2
Configure Your Workflow
| Field | Description | Example |
|---|---|---|
| Package | The package to publish to | my-codemod or @org/my-codemod |
| Repository Owner | GitHub org or username | my-org |
| Repository Name | Repository name | my-codemod-repo |
Optional Restrictions
Add restrictions for additional security:| Restriction | Description | Example |
|---|---|---|
| Workflow Path | Only allow specific workflow files | .github/workflows/publish.yml |
| Environment | Require GitHub Environment approval | production |
| Ref Pattern | Only allow specific git refs | refs/tags/v* |
Manual OIDC Setup
If you prefer not to use the action, you can manually obtain and use the OIDC token:Troubleshooting
No trusted publisher found
No trusted publisher found
Verify your trusted publisher configuration matches:
- Repository owner (case-insensitive)
- Repository name (exact match)
- Any configured restrictions (workflow path, environment, ref pattern)
Permission denied
Permission denied
Ensure your workflow has the required permissions:
Token audience mismatch
Token audience mismatch
The OIDC token audience must be
https://codemod.com. If using a custom registry, configure GITHUB_OIDC_AUDIENCE on the server.Comparison
| Feature | Interactive Login | API Keys | Trusted Publishers |
|---|---|---|---|
| Secrets to manage | None | Yes | None |
| Works locally | Yes | Yes | No |
| Works in CI/CD | No | Yes | GitHub Actions only |
| New package publish | Yes | Yes | Yes* |
| Token lifetime | Long-lived | Long-lived | ~5 minutes |
| Rotation needed | No | Recommended | No |
| UI configuration | None | Create key | None for org scopes** |
Best Practices
Use Trusted Publishers
For GitHub Actions, prefer trusted publishers over API keys. No secrets to leak or rotate.
Restrict Access
When using trusted publishers, add restrictions like environment protection for sensitive packages.
Rotate API Keys
If using API keys, rotate them periodically and use the minimum required permissions.
Tag Releases
Use git tags and GitHub releases to trigger publish workflows for clear version history.