Comments (6)
Two things of note:
- File storage of any kind (configuration, data, temp, auth) should respect the XDG basedir specification: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
So if you write your own storage mechanism, be kind to your users and respect the spec!
- For auth information in particular, that data should be stored in
netrc
https://www.gnu.org/software/inetutils/manual/html_node/The-_002enetrc-file.html
from nodejs-cli-apps-best-practices.
Sounds like a good topic to discuss. We cover that in general at https://github.com/lirantal/nodejs-cli-apps-best-practices#13-stateful-data
What were you thinking about more specifically?
from nodejs-cli-apps-best-practices.
Something like npm login
but for accessing Google APIs.
Now Google requires OAuth 2.0 login, for which we need to provide a callback URL, which I guess is not possible in CLI applications. Whereas, npm accepts username & password directly through CLI which they must be encoding before sending to their servers. But since there's no Google API to directly accept username & password, what would be the best approach to achieve this?
from nodejs-cli-apps-best-practices.
Looks like OAuth 2.0 supports setting the callback URL to localhost
Google also provides Node.js SDK for authentication - google-auth-library-nodejs
from nodejs-cli-apps-best-practices.
@jasonkarns we do recommend the configstore
module which follows that convention if it that variable exists. Perhaps you want to update that section with some highlights in the Details part?
from nodejs-cli-apps-best-practices.
About authentication - I don't think localhost callback would work or makes sense. Have you seen how the Snyk CLI (snyk
) does authentication with Google or GitHub auth? it basically spins up a URL that you visit with a specific token, and then the CLI makes a phone-home periodical pings to check if the account described with this token is registered or not.
I've implemented a similar logic in a personal project.
from nodejs-cli-apps-best-practices.
Related Issues (20)
- Idea: add a section for CLI tools
- Updates needed for up to date Node.js runtime features
- Do you have plans to translate it into other languages? HOT 1
- New Practice: Distinguish STDOUT from STDERR
- Caveat: Accept STDIN somewhat counter to Empathetic CLI HOT 1
- [author required] New Practice: Support shell completion HOT 7
- Updating layout suggestions HOT 26
- Request: New experience best practice request: i18n HOT 2
- New Distribution Practice: Exclude unnesessary files from npm publish HOT 5
- GitLocalize: Problems with the structure of the .md file HOT 5
- Upgrade severals examples from require to import. HOT 1
- New Experience best practice request: version information HOT 7
- New feature: document other CLI related resources HOT 5
- New feature: document a new section for popular command line frameworks HOT 7
- Cleanup configuration files (if any) when uninstalling the package HOT 5
- Add the Crowdin internationalization integration tool to the project HOT 15
- remove 2.3 Cleanup configuration files chapter as it does not work since npm v7 HOT 2
- Can I use GitLocalize to translate documents? HOT 9
- Good first issue: add Crowdin badge to the repository
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodejs-cli-apps-best-practices.