Include the dependencies

For Apache Maven:


For Gradle:

compile 'org.springframework.boot:spring-boot-starter-security:1.5.6.RELEASE'
compile ''


Configure your Spring properties via environment variables, system properties, your application.yaml:

      # From OIDC app
      clientId: # clientId
      clientSecret: # clientSecret
      # From Authorization Server's metadata
      accessTokenUri: # token_endpoint
      userAuthorizationUri: # authorization_endpoint 
      clientAuthenticationScheme: form
      # from your Auth Server's metadata, check .well-known/openid-configuration 
      # if not in .well-known/oauth-authorization-server
      userInfoUri: # userinfo_endpoint
      preferTokenInfo: false

Annotate your Application

Just add a @EnableOAuth2Sso annotation to your application, for example:

public class ExampleApplication {
    public static void main(String[] args) {, args);

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 support or take a look at this blog post that describes the steps and configuration in detail.