I'm basing my take on this on your comments here, Dave. If I understand you correctly, I should be able to just make that series of calls and be able to access OAuth2-protected resources directly through the OAuth2RestTemplate. Is that correct?
What I'm trying to do at the moment is create a command-line tool that accesses the sparklr2 auth/resource provider to download the pictures for a particular user. This comes very close to the functionality I need to be able to implement in my own project, where we need to be able to provide access to the server for a variety of spawned processes without passing usernames and passwords all over the place.
So I have this:
The problem is that I don't see where I'd set the credentials, i.e. the user name and password. And I'm also thinking... that looks too simple I mean, I'd love it if this is all I need to do, but am I missing anything?
OAuth2ProtectedResourceDetails resource = new ClientCredentialsResourceDetails();
DefaultAccessTokenRequest accessTokenRequest = new DefaultAccessTokenRequest();
OAuth2ClientContext context = new DefaultOAuth2ClientContext(accessTokenRequest);
OAuth2RestTemplate template = new OAuth2RestTemplate(resource, context);
ResponseEntity<String> value = template.getForEntity("http://localhost:8080/sparklr2/photos?format=xml", String.class);