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
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 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.
Please visit our Okta Developer Forums.