Question: how oauth2 works in spring?
Answer: A Resource Server serves resources that are protected by the OAuth2 token. Spring OAuth2 provides an authentication filter that handles protection. The @EnableResourceServer annotation enables a Spring Security filter that authenticates requests via an incoming OAuth2 token.