Authentication Methods
Ralph supports two authentication methods for GitHub integration. This page explains each option in detail.
OAuth Device Flow
The recommended authentication method.
How It Works
ralph auth login- Ralph requests a device code from GitHub
- You receive a code and URL to visit
- In your browser, you authorize Ralph
- Ralph receives an access token automatically
Advantages
- No token management: Tokens are handled automatically
- Secure: Uses GitHub’s official OAuth flow
- Minimal permissions: Only requests what’s needed
- Token refresh: Credentials stay valid
Step-by-Step
$ ralph auth login
Visit this URL to authenticate:
https://github.com/login/device
Enter this code: ABCD-1234
Waiting for authorization...- Open the URL in your browser
- Log in to GitHub if needed
- Enter the code
ABCD-1234 - Click “Authorize” to grant access
- Return to your terminal
✓ Authentication successful
Logged in as: your-usernameRevoking Access
You can revoke Ralph’s access from GitHub:
- Go to GitHub Settings > Applications > Authorized OAuth Apps
- Find “Ralph” in the list
- Click “Revoke”
Then log out locally:
ralph auth logoutPersonal Access Token
An alternative method using GitHub personal access tokens.
When to Use
- OAuth is blocked by your organization
- You need more control over permissions
- You prefer token-based auth
Creating a Token
- Go to GitHub Settings > Developer settings > Personal access tokens > Tokens (classic)
- Click “Generate new token (classic)”
- Set a descriptive name: “Ralph CLI”
- Select scopes:
repo(required)read:user(recommended)
- Click “Generate token”
- Copy the token (it won’t be shown again)
Setting the Token
ralph github set-token ghp_xxxxxxxxxxxxxxxxxxxxToken Security
- Treat tokens like passwords
- Never commit tokens to git
- Rotate tokens periodically
- Use fine-grained tokens if available
Fine-Grained Tokens
GitHub supports newer “fine-grained” tokens with more precise permissions. To use one:
- Go to GitHub Settings > Developer settings > Personal access tokens > Fine-grained tokens
- Set token name and expiration
- Select the repository
- Grant permissions:
- Repository permissions: Contents (Read and write)
- Repository permissions: Pull requests (Read and write)
- Generate and copy the token
- Set it:
ralph github set-token github_pat_...
Comparison
| Feature | OAuth | Personal Access Token |
|---|---|---|
| Setup complexity | Low | Medium |
| Token management | Automatic | Manual |
| Permission scope | Minimal | You choose |
| Expiration | Handled | Manual rotation |
| Organization support | Usually yes | Depends on policy |
Troubleshooting
”Not authorized” error
Re-authenticate:
ralph auth logout
ralph auth loginToken expired
Generate a new token and update:
ralph github set-token <new-token>Organization restrictions
Some organizations restrict OAuth apps. Check with your admin or use a personal access token with appropriate permissions.
Next Steps
- PR Creation — Configure pull request creation
- Configuration — Full configuration reference