Auth0 Home Blog Docs

Getting 401s all of the sudden with Spring MVC JPA


#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"
}