Skip to content
Branch: master
Clone or download
Pull request Compare This branch is 4 commits ahead of moksamedia:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.

Java and MongoDB Example

This example app shows how to build a CRUD API with Java, MongoDB, and Spring Boot. See Build a CRUD API with Java and MongoDB to see how it was built.


Java 11: This project uses Java 11. If you don’t have Java 11, you can install OpenJDK. Instructions are found on the OpenJDK website.

Okta Developer Account: Go to the Okta website and sign up for a free developer account, if you haven’t already.

Okta has Authentication and User Management APIs that reduce development time with instant-on, scalable user infrastructure. Okta's REST API and makes it easy for developers to authenticate, manage, and secure users + roles in any application.

Getting Started

To install this example application, run the following commands:

git clone

Create a New OIDC App in Okta

If you don't have an Okta developer account, please create one. Then, create a new OIDC app on Okta:

  1. Log in to your developer account, navigate to Applications > Add Application.
  2. Select Web > Next.
  3. Give the application a name
  4. Under Login redirect URIs, add a new URI:
  5. Under Grant types allowed, check Implicit (Hybrid).
  6. The rest of the default values will work. Click Done.

Steps 4 & 5 are only needed if you want to use the OpenID Connect Debugger to generate a test token.

Configure the Resource Server

You need to add the Issuer URI from your Okta account to the src/main/resources/ file. To find your Issuer URI, go to API -> Authorizaiton Servers.


Run the Resource Server

To run the SpringMVC resource server, run:

./gradlew bootRun

Then use OIDC Debugger to create an access token. Save the access token as a variable in your terminal:


Now you can make authenticated and authorized requests.

$ http :8080 "Authorization: Bearer $TOKEN"

HTTP/1.1 200
Cache-Control: no-cache, no-store, max-age=0, must-revalidate

    "_links": {
        "fridge": {
            "href": "http://localhost:8080/fridge{?page,size,sort}",
            "templated": true
        "profile": {
            "href": "http://localhost:8080/profile"


Please post any questions as comments on the blog post or post them to Stack Overflow with the okta tag.


Apache 2.0, see LICENSE.

You can’t perform that action at this time.