Hi,
Can someone guide me with OAuth2RestTemplate for "stateless" services?
OAuth2RestTemplate keeps obtained token in OAuth2ClientContext or in ClientTokenServices (in AccessTokenProviderChain) inside itself.
If I wanna to create oAuth2RestTemplate in runtime (and oauth resource also), what should I do (for redirect resource details)?
Right now I plan to implement ClientTokenServices and use it as singleton. Something, like this:
Is it best practice or I miss something?Code:@Autowired private ClientTokenServices clientTokenServices; ......................... ......................... AuthorizationCodeResourceDetails facebookResource = new AuthorizationCodeResourceDetails(); ......................... OAuth2RestTemplate facebookRestTemplate = new OAuth2RestTemplate(facebookResource); AccessTokenProviderChain providerChain = new AccessTokenProviderChain(Arrays.<AccessTokenProvider> asList(new AuthorizationCodeAccessTokenProvider(), new ImplicitAccessTokenProvider(), new ResourceOwnerPasswordAccessTokenProvider(), new ClientCredentialsAccessTokenProvider())); providerChain.setClientTokenServices(clientTokenServices); facebookRestTemplate.setAccessTokenProvider(providerChain); OAuth2AccessToken accessToken = facebookRestTemplate.getAccessToken();
And what scope is set for beans, created by <oauth:resource /> and <oauth:rest-template /> tags?
thanks in advance


Reply With Quote
