Integrate Spring MVC framework with Okta OpenId / Oauth2

Hi Team,

Please help me on the Spring MVC and Okta Oauth2 integration. It will be of real help if some one can point me to github links on the same

Thanks in advance.

Hi, @Nataraj. Please take a look at the following samples: GitHub - okta/samples-java-spring: Spring Boot samples

Hi @louie , Thanks for the link, But I am specifically looking for Spring MVC sample, Also like to know where is the controller for the action : /oauth2/authorization/okta. Also, Would like to know how to get the Okta hosted login form to enter username and password.

Thanks in Advance

I am new to the Okta SSO, trying to get the Access token using below code.Am i using right API and package to do this? Please suggest, Thanks in advance

     private getAccessToken(
                AuthorizationCode authorizationCode, String currentUri)
                throws Throwable {
            String authCode = authorizationCode.getValue();
            ClientCredential credential = new ClientCredential(clientId,
   context = null;
   result = null;
            java.util.concurrent.ExecutorService service = null;
            try {
                service = Executors.newFixedThreadPool(1);
                context = new AuthenticationContext("", true,
                Future<AuthenticationResult> future = context.acquireTokenByAuthorizationCode(authCode, new URI(currentUri), credential, null);
                result = future.get();
            } catch (ExecutionException e) {
                throw e.getCause();
            } catch(InterruptedException e){
            } catch(MalformedURLException e){
                LOGGER.error("Malformed URL :"+e);
            }finally {

            if (result == null) {
                throw new ServiceUnavailableException(
                        "authentication result was null");
            return result;