So you want to use Oauth2 in your application, and you want to use the password flow.
You can use the spring security oauth2-resource-server project to implement a resource server.
In your resource server you can use the ResourceOwnerPasswordResourceDetails to provide the client_id, client_secret, username and password,
The Oauth2RestTemplate can be used to call the resource server.