The second XML that you inserted here is spring XML for oauth-provider and protected-resource , which in your case runs in the same webapp (you can separate them, of course, if you want).
The client (first nested XML) is a different story. If you understand correctly, you want your client to work without spring help (to be a regular webapp, not spring-security-oauth-client webapp).
You need to understand how oAuth works: the client is trying to get to a secure resource; if it does not have an access token, it is redirected to oAuth-provider (which displays the login page and provides the token). By standard, the token request MUST contain the "redirect-uri" parameter, so after successful login, the oAuth provider knows where to redirect the client. The oAuth client does this for you, and if you remove the "oauth client" from your web.xml, now you have to implement it yourself.
Thanks for your reply. But I still don't understand how spring security affects my oAuth client. And can I use spring -oauth (spring -mvc) without spring -security for the client side?
When you write this line in your XML:
< oauth:client id="oauth2ClientFilter" />
this means that you are using spring -security-oauth, which is a package designed for oauth, built on spring -security. If you dig, it puts in a chain a special filter (OAuth2ClientContextFilter), which processes the oAuth material that is relevant to the client. One of them sends a request with all parameters ("redirect-uri" is one of them).
If you decide NOT to use spring-security-oauth, well, you will have to implement this logic yourself ...
Hope this helps!
Ohadr source share