On This Page

Okta Java/Spring Quickstart

Now that your users can sign in, let's add authentication to your server.

Include the dependencies

For Apache Maven:


For Gradle:

compile 'com.okta.spring:okta-spring-boot-starter:1.3.0'

Configure your properties

You can configure your applications properties with environment variables, system properties, or configuration files. Take a look at the Spring Boot documentation for more details.

An example application.properties file would look like:

Note: https://{yourOktaDomain} is different from your admin URL. Don’t include -admin in the value. When you copy your Okta domain from the Developer Console, you can find the correct value in the upper-right corner of the dashboard.

# Configure the callback URL to match the previous section

Customize the configuration (optional)

The OAuth 2.0 behavior can be customized the same way as using Spring Security directly:

public class WebConfig extends WebSecurityConfigurerAdapter {
    protected void configure(HttpSecurity http) throws Exception {

That's it! Open an incognito window (to ensure clean browser cache) and browse to http://localhost:8080/login you will be automatically redirected to the Okta login page.

You can read more about Spring's OAuth 2.0 support or take a look at this blog post that describes the steps and configuration in detail.