Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Spring boot oauth2 authorization server problems

Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all,

I have been trying to protect my APIs with spring oauth2. I have looked at and taken numerous examples, and it all looks easy enough using Spring 4.x, the @EnableAuthorizationServer, and so forth. However, despite trying in memory, jwt and jdbc, whenever I try to create a token using the /token endpoint, I see in my log output:
2017-01-19 12:21:05.047  WARN 30061 --- [243-8081-exec-4] o.s.web.servlet.PageNotFound             : No mapping found for HTTP request with URI [/api/error] in DispatcherServlet with name 'dispatcherServlet'

which makes me think I am missing something that allows the server forward to some page that needs to be sent back as an error response.   I dont have anything hosted at /api/error endpolint, I assumed that the magic of Spring OAUTH2 and such properly returned a JSON chunk of error and the 401 error code.

From time to time I seem to send in the right POST call that generated a different error, basically telling me:
No adapter for handler [public org.springframework.http.ResponseEntity<>

So this last one makes me think that the auth worked, but somehow I am again missing something on my runtime classpath to handle the OAuth2AccessToken response type. Which again is baffling to me because I assumed with all the POM dependencies set up, and annotations in my code configured as other examples show, it just all magically worked. Nothing I have found explains anything else on configuration, etc for either of these issues I am seeing.

I built a Postman request to http://<ip>:80801/api/token?client_id=foo&grant_types=client_credentials

That is a POST call, with Accept: application/json set as a header.  

I am trying to set up the ability for an API consumer to create a token that they can then use to make API calls with e.g. Bearer <token> in Authorization header.

Any help would be appreciated.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic