Protecting a RESTful API using OAuth2
Protecting a resource – in this case, a RESTful API – is the core functionality of OAuth. In OAuth2, a resource server delegates authorization to access a third-party server – that is, the authorization server. In this recipe, you’ll learn how to configure a RESTful API application so that it can authorize the requests that are issued by your Spring Authorization Server.
We will continue with our samples for football data management. You will protect your Football API by only allowing clients who have been granted access by our Authorization Server.
Getting ready
In this recipe, you will reuse the Authorization Server you created in the Setting up Spring Authorization Server recipe. If you haven’t completed that yet, you can use the authorization server that I’ve prepared. You can find it in this book’s GitHub repository at https://github.com/PacktPublishing/Spring-Boot-3.0-Cookbook, in...