Code Monkey home page Code Monkey logo

okta-node-cli-example's Introduction

Okta Node.js Command Line Application Example

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:

To successfully run this project you will need to:

  1. Clone or download the source code.
  2. Run npm install from the command line in the project folder.
  3. Copy .env.sample to .env
  4. Install the Okta CLI and run okta register to sign up for a new account. Use okta login if you already have an account.
  5. Run okta apps create. Select the default app name, or change it as you see fit. Choose Native and use http://localhost:8080/callback for the Redirect URI. Set the Logout Redirect URI to http://localhost:8080.
  6. Update .env with your Issuer and application's Client ID
  7. 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!

okta-node-cli-example's People

Contributors

dependabot[bot] avatar reverentgeek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

okta-node-cli-example's Issues

pkce-login doesn't work globally

I followed all the instructions for the set up as referenced in the blog post for creating a command line app with Node.js.

However, running pkce-login only works when running in the /hello-cli directory since the .env credentials only exist in that directory, and by default, dotenv.config() only looks in current working directory.

As a result, the credentials will not get read in when executing pkce-login from any directory other than /hello-cli.

As a workaround, I passed the absolute path of .env to dotenv.config and it worked, but I feel like this is a hacky workaround:

const dotenv = require("dotenv");
const result = dotenv.config({ path: '/Users/robertluo/github/hello-cli/.env' });
if(result.error) {
  throw result.error;
}

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.