8000 Best practices for storing API tokens in CLI tools? · cli cli · Discussion #12488 · GitHub
[go: up one dir, main page]

Skip to content
Discussion options

You must be logged in to vote

For CLI tools, the safest approach is to avoid hardcoding tokens or storing them in plain text files.

Common best practices include:

  1. Environment variables
    Using environment variables is usually the first layer. Tools like dotenv are fine for development, but the .env file should never be committed to the repository.

  2. OS-level secure storage
    For production-ready CLI tools, it’s better to rely on the operating system’s credential manager:

  • macOS: Keychain
  • Windows: Credential Manager
  • Linux: Secret Service / keyring

Many CLI tools use libraries that abstract this, such as keyring (Python) or node-keytar (Node.js).

  1. Configuration files with restricted permissions
    If tokens must be store…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Mani19492
Comment options

Answer selected by Mani19492
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
0