No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Latest commit 5e3b746 Oct 20, 2018

Example API Using GraphQL, Express, and Okta

This is an example API, showing how to create a GraphQL endpoint in Node. The mutations are protected behind authentication provided by Okta. To follow along step-by-step, check out the blog post.

Prerequisites: Node.js.

Getting Started

To install this example application, run the following commands:

git clone
cd okta-express-graphql-example
npm install

This will install a local copy of the project. You will need to set up some environment variables before the app will run properly.

To integrate Okta's Identity Platform for user authentication, you'll first need to:

You will need to create an application in Okta:

  • Log in to your Okta account, then navigate to Applications and click the Add Application button
  • Select Web and click Next
  • Give your application a name (e.g. "GraphQL Express")
  • Change the Base URI to http://localhost:4000/ and the Login redirect URI to http://localhost:4000/implicit/callback, then click Done
  • Save your Client ID and Client Secret for later

Your Okta application should have settings similar to the following:

Okta Application Settings

You will also need to create an API token in Okta:

  • Log in to your Okta account, then navigate to API > Tokens and click the Create Token button
  • Enter a name that will help you remember what this is used for (e.g. "GraphQL Express")
  • Save the provided token value for later
    • This will only be displayed once. If you lose it, you will need to create another API token

Now create a file called .env in the project root and add the following variables, replacing the values with your own from the previous steps.



You also need an app secret. One way to get a random APP_SECRET is to use the following command line, which will generate a random value and add it to your .env file.

echo "APP_SECRET=`openssl rand -base64 32`" >> .env

Now you can run the React frontend with the following command:

npm start


This example uses the Okta Node SDK, the Okta JWT Verifier, and the Okta OIDC Middleware.


Please raise an issue if you find a problem with the example application, or visit our Okta Developer Forums. You can also email if would like to create a support ticket.


Apache 2.0, see LICENSE.