Getting a no plugin error for oauth2.issuer=https and IllegalStateException for Client id being empty

Hello,

I am trying to run my application using the okta-spring-starter, but I am getting these errors when running these following commands:

  • “No plugin found for prefix ‘.oauth2.issuer=https’ in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo]” for running mvn -Dokta.oauth2.issuer=https://dev-85796264.okta.com/oauth2/default -Dokta.oauth2.clientId=0oa1mjsjqg51D1UOb5d7 -Dokta.oauth2.clientSecret=a9Gpd0irLCexpqZrwwcdvCWzCVNpJGLvUShF0Bq8

  • “java.lang.IllegalStateException: Client id must not be empty” for running mvn

My .yml file is as follows:

spring: 
  security: 
    oauth2: 
      issuer: https://dev-85796264.okta.com/oauth2/default
      client:
        provider: 
          okta: 
            client-id: '0oa1mjsjqg51D1UOb5d7'
            client-secret: 'a9Gpd0irLCexpqZrwwcdvCWzCVNpJGLvUShF0Bq8 '
            user-name-attribute: email

okta: 
  oauth2: 
    redirect-uri: authorization-code/callback
    postLogoutRedirectUri: 'http://localhost:8080/logout/callback'
    scopes: 
    - profile
    - email 
    - openid

My pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.5.4</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>

	<groupId>project.hackathon.okta.seleucia</groupId>
	<artifactId>seleucia</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	
	<name>seleucia</name>
	<description>A project for the Okta Identity Early Access Hackathon</description>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<java.version>1.8</java.version>
	</properties>
	<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

		<dependency>
            <groupId>com.okta.spring</groupId>
            <artifactId>okta-spring-boot-starter</artifactId>
            <version>2.1.0</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.springframework.security</groupId>
			<artifactId>spring-security-test</artifactId>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<optional>true</optional>
		</dependency>

		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-lang3</artifactId>
		</dependency>

		<!-- <dependency>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-resources-plugin</artifactId>
			<version>3.2.0</version>
		</dependency> -->
		

	</dependencies>

	<build>
		<defaultGoal>spring-boot:run</defaultGoal>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <fork>false</fork>
                </configuration>
            </plugin>
        </plugins>

		<pluginManagement>
			<plugins>
							<!--
				<plugin>
					<groupId>org.springframework.boot</groupId>
					<artifactId>spring-boot-maven-plugin</artifactId>
					<configuration>
						<excludes>
							<exclude>
								<groupId>org.projectlombok</groupId>
								<artifactId>lombok</artifactId>
							</exclude>
						</excludes>
					</configuration>
				</plugin>

				<plugin>
					<artifactId>exec-maven-plugin</artifactId>
					<groupId>org.codehaus.mojo</groupId>
					<executions>
						<execution>
							<id>npm start the react app</id>
							<phase>generate-resources</phase>
							<goals>
								<goal>exec</goal>
							</goals>
							<configuration>
								<workingDirectory>src/seleucia-ui</workingDirectory>
								<executable>npm</executable>
								<arguments>
									<argument>run</argument>
									<argument>build</argument>
								</arguments>
							</configuration>
						</execution>
					</executions>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugin</groupId>
					<artifactId>maven-resources-plugin</artifactId>
					<version>3.2.0</version>
					<executions>
						<execution>
							<id>Copy React App into Spring Boot target static foldier</id>
							<phase>process-resources</phase>
							<goals>
								<goal>copy-resources</goal>
							</goals>
							<configuration>
								<outputDirectory>target/classes/static</outputDirectory>
								<resources>
									<resource>
										<directory>src/seleucia-ui/build</directory>
										<filtering>true</filtering>
									</resource>
								</resources>
							</configuration>
						</execution>
					</executions>
				</plugin>
 -->
				<plugin> 
					<artifactId>maven-compiler-plugin</artifactId>
					<configuration>
						<forceJavacCompilerUse>true</forceJavacCompilerUse>
					</configuration>
				</plugin>

				<plugin>
					<artifactId>maven-assembly-plugin</artifactId>
					<configuration>
					  <descriptorRefs>
						<descriptorRef>jar-with-dependencies</descriptorRef>
					  </descriptorRefs>
					</configuration>
				  </plugin>

			</plugins>
		</pluginManagement>
	</build>

</project>

What is causing my project to throw these errors?

Thank you for your feedback.

Hello,

If you are trying to use Springs OAuth Okta provider I think you want to setup the yaml file like,

spring:
  security:
    oauth2:
      client:
        provider:
          okta:
            issuer-uri: https://{OKTA_ORG}/oauth2/{AUTHORIZATION_SERVER}
        registration:
          okta:
            client-id: {CLIENT_ID}
            client-secret: {CLIENT_SECRET}
            scope: openid,profile,email,groups

If you are trying to use the Okta Spring boot starter I suggest following the samples from,

Documentation for the SDK can be found at,