This project is the sample CLI application code for the blog post Build a Command Line Application with Node.js. This sample app demonstrates using Node.js to build a CLI application that can use PKCE to authenticate with an OAuth 2.0 API. Please read the blog post for more information!
To use this code, you will need the following:
- A recent version of Node.js downloaded and installed
- A good text editor, such as Visual Studio Code
- A free Okta developer account
To successfully run this project you will need to:
- Clone or download the source code.
- Run
npm install
from the command line in the project folder. - Copy
.env.sample
to.env
- Install the Okta CLI and run
okta register
to sign up for a new account. Useokta login
if you already have an account. - Run
okta apps create
. Select the default app name, or change it as you see fit. Choose Native and usehttp://localhost:8080/callback
for the Redirect URI. Set the Logout Redirect URI tohttp://localhost:8080
. - Update
.env
with your Issuer and application's Client ID - Install the CLI app globally using
npm install -g .
After installing the CLI app globally, you will have two commands you can use: hello
and pkce-login
.
Enjoy!