@Before public void init() throws Exception { tokenServices.setClientDetailsService( new InMemoryClientDetailsServiceBuilder() .withClient("client") .authorizedGrantTypes("authorization_code") .scopes("read") .secret("secret") .and() .build()); enhancer.setTokenEnhancers(Arrays.<TokenEnhancer>asList(jwtTokenEnhancer)); jwtTokenEnhancer.afterPropertiesSet(); tokenServices.setTokenStore(new JwtTokenStore(jwtTokenEnhancer)); tokenServices.setTokenEnhancer(enhancer); }