Auth0 Home Blog Docs

Getting 401s all of the sudden with Spring MVC JPA

spring
java
quickstart
spring-boot
#1

I am trying to integrate with my Spring Boot app. I used the example provided here. When I swap out my creds in the auth0.properties and try to login I get an infinite loop back to the login. When I debug it appears this is happening here…

private void handle(HttpServletRequest req, HttpServletResponse res) throws IOException {
        try {
            Tokens tokens = controller.handle(req);
            com.auth0.example.security.TokenAuthentication tokenAuth = new com.auth0.example.security.TokenAuthentication(JWT.decode(tokens.getIdToken()));
            SecurityContextHolder.getContext().setAuthentication(tokenAuth);
            res.sendRedirect(redirectOnSuccess);
        } catch (AuthenticationException | IdentityVerificationException e) {
            e.printStackTrace();
            SecurityContextHolder.clearContext();
            res.sendRedirect(redirectOnFail);
        }
    }

It seems to say…

com.auth0.exception.APIException: Request failed with status code 401: Unauthorized

I don’t get it do I need to delete and recreate my app? This was working at one point.

#2

I just double checked and it is also an authorized application. I found the log as well…

{
  "date": "2018-05-19T18:21:43.270Z",
  "type": "feacft",
  "description": "Unauthorized",
  "connection_id": "",
  "client_id": "MyIDHere",
  "client_name": null,
  "ip": "####",
  "user_agent": "okhttp/3.7.0",
  "hostname": "jackiergleason.auth0.com",
  "user_id": "",
  "user_name": "",
  "auth0_client": {
    "name": "auth0-java",
    "version": "1.0.0"
  },
  "log_id": "90020180519182143272556801611932046490087660842028892226"
}
#4

Hey there @jackiegleason, first let me apologize for the delay in response to your topic. Next I wanted to let you know that as I work to recreate this error internally, I will be sure to share this information with our team. Thank you for bringing this to our attention @jackiegleason and @jitterted and if there is any additional details you can share about reproducing this issue we would happy to take a look. Thanks!