Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Node and OAuth on the Command Line -- Twin Citi...

Node and OAuth on the Command Line -- Twin Cities Code Camp 2018

Node provided a way to bring JavaScript out of the browser and on to server and desktop. In addition to building web applications, now you can build command line interface applications using JavaScript! Come explore some tools and libraries that will help you in your development, and even learn how to complete an OAuth flow from the command line.

Scott McAllister

April 21, 2018
Tweet

More Decks by Scott McAllister

Other Decks in Programming

Transcript

  1. Why CLI? • Quick interactions with sheets and users •

    Great for prototyping • Shell scripting automation • Comfortable for IT admins already living in command line • Relatively small amount of dev work
  2. Why Node? • JavaScript Ecosystem ◦ Large number of developers

    ◦ Large number of available libraries • npm - Platform independent package manager ◦ Largest package repository in the world • Runs well on all platforms -- macOS, Windows, Linux, etc • Shallow learning curve for JS developers
  3. Why Node? • Important that it's easy to start hacking

    on a new command and contribute back. • Performance isn’t generally a big issue ◦ Usually just waiting on an API call • Not likely to contain complex code
  4. NPMCompare Tool that allows you to compare the features of

    comparable npm packages https://npmcompare.com/compare/commander,minimist,nomnom,optimist,yar gs
  5. Commander.js • Parses command-line arguments and options • Able to

    handle Git-like subcommands ◦ sscli sheet list ◦ sscli auth login • Provides declarative and readable organization • Automatically generates help screens
  6. OAuth 2 • An open standard for providing secure access

    to user accounts on an HTTP service. • In other words, a user can get access to their data from a third-party application. • Limit user's scope of access
  7. OAuth 2: What we need • Client ID • Client

    Secret • Redirect URL • Access Scopes
  8. OAuth 2: What we need • Client ID • Client

    Secret • Redirect URL • Access Scopes
  9. fs-extra Library for interacting with the file system. fs-extra adds

    file system methods that aren't included in the native fs library. Adds promise support to fs methods.
  10. Further Reading google-apps-script CLI project (Google OAuth Example) https://github.com/maartendesnouck/google-apps-script Smartsheet-CLI

    https://github.com/smartsheet-samples/smartsheet-cli NPMCompare https://npmcompare.com/compare/commander,minimist,nomnom,optimist,yargs