- Overview
- Current Login Modes in GitNapse
- OAuth Device Flow with octocrab
- GitHub Configuration
- Commands
- TUI Behavior
- Security Notes
GitNapse supports multiple authentication paths and now includes OAuth device login implemented
with octocrab. The implementation is optimized for terminal UX and avoids embedding
user credentials in CLI history.
| Mode | How it Works | Best For | Storage |
|---|---|---|---|
| Environment token | Reads GITHUB_TOKEN at runtime |
CI/CD and ephemeral sessions | Not persisted by app |
| Manual token | gitnapse auth set stores a token |
Local personal workflow | User config directory, secure file permissions on UNIX |
| OAuth device flow | gitnapse auth oauth login ... uses browser authorization and exchanges token via octocrab |
Safer interactive sign-in without pasting long tokens | Stored in OS keyring when available; secure file fallback otherwise |
- GitNapse requests a device code from GitHub using octocrab against
https://github.com. - GitNapse tries to open
verification_uriin your default browser automatically. - If auto-open is unavailable, the terminal shows a clickable OSC8 hyperlink (when terminal supports it) plus the plain URL.
- User authorizes in browser with GitHub account.
- GitNapse polls token endpoint using octocrab's recommended flow logic, respecting
intervalandslow_downresponses. - The resulting OAuth access token is stored securely and then validated against
/user.
To use OAuth login, you need an OAuth App in GitHub settings.
- Create an OAuth App in GitHub developer settings.
- Copy the Client ID from the app.
- For terminal device flow, no local redirect listener is required.
- Use minimum scopes first (recommended:
read:user), then addrepoonly if private repository access is needed.
GitNapse accepts either GITNAPSE_GITHUB_OAUTH_CLIENT_ID or compatibility fallback
GITHUB_CLIENT_ID as Client ID source, and includes a built-in default Client ID for the official GitNapse OAuth app.
If you currently have a GitHub App but not an OAuth App, create the OAuth App as a separate credential set for user login.
One-time login with explicit Client ID:
gitnapse auth oauth login --client-id YOUR_OAUTH_CLIENT_ID --scope read:user --scope repo
Use environment for Client ID:
export GITNAPSE_GITHUB_OAUTH_CLIENT_ID=YOUR_OAUTH_CLIENT_ID
gitnapse auth oauth login --scope read:user --scope repo
Compatibility environment variable:
export GITHUB_CLIENT_ID=YOUR_OAUTH_CLIENT_ID
gitnapse auth oauth login --scope read:user
TUI shortcut:
# Inside the app, press:
o
The app performs a quick OAuth/authentication status check and prints guidance to use CLI login.
Short timeout tuning:
gitnapse auth oauth login --client-id YOUR_OAUTH_CLIENT_ID --timeout-secs 1200
Check OAuth state:
gitnapse auth oauth status
- OAuth interactive login is CLI-first for reliability across terminal multiplexers and alternate screen modes.
- Use
gitnapse auth oauth loginin normal terminal mode for device flow URL/code interaction. - Inside TUI, key
ois intentionally reduced to quick status/help behavior.
- Client secret is intentionally not required for this terminal device flow implementation.
- OAuth access token is never printed back to terminal output.
- Primary storage is OS keyring (Credential Manager on Windows, Keychain on macOS, Secret Service/libsecret on Linux when available).
- WSL and no-keyring environments automatically fallback to local file storage with strict UNIX permissions (
0600). - OAuth session metadata is persisted separately (expiry, refresh token, scopes, client id) to support safer session lifecycle handling.
- If
GITNAPSE_GITHUB_OAUTH_CLIENT_SECRETorGITHUB_CLIENT_SECRETis present, GitNapse attempts refresh-token exchange when access token is near expiry. - Prefer least-privilege scopes and rotate/revoke tokens when no longer needed.
- For shared machines, prefer environment-based or ephemeral auth over persistent local token storage.
- On logout (
gitnapse auth clear), GitNapse removes credentials from keyring and also deletes fallback file if present.
Current implementation uses OS keyring when available and falls back to secure local file storage in unsupported environments (for example WSL/headless Linux sessions without keyring service).
- If you previously saw a rustls
CryptoProviderpanic, update to this build; GitNapse now installs a rustls provider explicitly before OAuth login. .envis loaded at startup, soGITHUB_CLIENT_IDand related auth vars are available without manual export.- If browser auto-open does not work in your terminal/session, copy the displayed URL and open it manually.