I’ve followed this tutorial on OAuth2 client setup. Unfortunately, the authorization code redirect - i.e. a redirect to http://localhost:8080/auth/login - results in 404 error. Has anyone else encountered such an issue? If so, what was the cause and solution?
I would suggest using one of our tutorials to see how to authentication to Spring Boot with OAuth. For example: https://developer.okta.com/blog/2017/12/04/basic-crud-angular-and-spring-boot
To summarize, add the following dependencies to your pom.xml
:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
Create a new app in Okta, choose “Web” as the type, and http://localhost:8080/login
as the redirect URI. Add the following properties to your src/main/resources/application.yml
and make sure the values match your Okta tenant.
security:
oauth2:
client:
access-token-uri: https://{yourOktaDomain}.com/oauth2/default/v1/token
user-authorization-uri: https://{yourOktaDomain}.com/oauth2/default/v1/authorize
client-id: {clientId}
scope: openid profile email
resource:
user-info-uri: https://{yourOktaDomain}.com/oauth2/default/v1/userinfo
token-info-uri: https://{yourOktaDomain}.com/oauth2/default/v1/introspect
prefer-token-info: false
Add the @EnableOAuth2Sso
annotation to your main Spring Boot Application.java
class and you should be good to go!
1 Like
I have the same issue. How did you manage ?