Skip to content

okta-samples/okta-express-js-api-quickstart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Express API Quickstart Sample Code for Integrating with Okta

This repository contains a sample of protecting API endpoints using Okta in a Node Express API.

The sample uses the Okta JWT Verifier SDK. Read more about getting started with Okta and authentication best practices on the Okta Developer Portal.

This code sample demonstrates

  • Configuring Okta
  • Protecting routes
  • Verifying the JWT

Getting started

To run this example, run the following commands:

git clone https://github.com/okta-samples/okta-express-api-quickstart.git
cd okta-express-api-quickstart
npm ci

Create an OIDC organization in Okta

Create a free Okta Developer account to create your Okta organization. You can do this through the Okta CLI or through the Okta Developer admin dashboard.

When using the Okta CLI run the following command:

okta register

You will need your Okta domain and Audience.

Update server.js with your Okta settings.

const oktaJwtVerifier = new OktaJwtVerifier({
    issuer: 'https://{yourOktaDomain}/oauth2/default'
});
const audience = 'api://default';

Start the app by running

npm start

Use your favorite HTTP Client to call the API. For authenticated calls, follow the steps in Send a request to your API endpoint using Postman of the quick start.

Helpful resources

Help

Please visit our Okta Developer Forums.

About

Express API quick start sample

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published