Giter Site home page Giter Site logo

Comments (6)

jasonkarns avatar jasonkarns commented on July 24, 2024 1

Two things of note:

  1. 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!

  1. 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.

lirantal avatar lirantal commented on July 24, 2024

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.

shreyas-a avatar shreyas-a commented on July 24, 2024

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.

shreyas-a avatar shreyas-a commented on July 24, 2024

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.

lirantal avatar lirantal commented on July 24, 2024

@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.

lirantal avatar lirantal commented on July 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.