I made my own implementation of ClientDetailsService:
@Service
public class JpaClientDetailsService implements ClientDetailsService {
@Autowired
private
I would say that the best solution is to be explicit - if you are autowiring a clientDetailsService - then say so.
@Autowired
ClientDetailsService myClientDetailsService;
@Override
public void configure(final AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
endpoints.setClientDetailsService(myClientDetailsService);
....
}
However, My problem was slightly different and the above solutions did not work. Here are the conditions that created it. I created a CustomTokenEndpointAuthenticationFilter - which required an instance of OAuth2RequestFactory. I created my instance of OAuth2RequestFactory with a call to endpoints.getOAuth2RequestFactory(); before the clientDetailsService had been set.
If The OAuth2RequestFactory gets created this way, DefaultOAuth2RequestFactory gets created with a default clientDetailsService, so even if you set the clientDetailsService later explicitly in the AuthorizationServerEndpointsConfigurer it will not be in the OAuth2RequestFactory used by your custom Filter.
So in sum in this edge case
public void configure(final AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
oAuth2RequestFactory = endpoints.getOAuth2RequestFactory();
endpoints.setClientDetailsService(myClientDetailsService);
...
}
wont work but
public void configure(final AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
endpoints.setClientDetailsService(myClientDetailsService);
oAuth2RequestFactory = endpoints.getOAuth2RequestFactory();
...
}
will.
Another way to be sure is to create your own OAuth2RequestFatory
oauth2RequestFactory = new DefaultTokenRequestFactory(myClientDetailsService);