No AuthenticationProvider found for UsernamePasswordAuthenticationToken - Spring-boot + Oauth2: Restful API
<p>i'm trying to build a Restful API with Spring-boot and oauth2 using hibernate.</p>

<p>i've made a CustomAuthenticationProvider to authenticate users from a database but im having the following response of the server</p>

<p><strong>NOTE:</strong> json response.</p>

<pre><code>error": "unauthorized",
"error_description": "No AuthenticationProvider found for org.springframework.security.authentication.UsernamePasswordAuthenticationToken"
}
</code></pre>

<p>here is my CustomAuthenticationProvider:</p>

<pre><code>@Component
public class CustomAuthenticationProvider implements AuthenticationProvider {
    public CustomAuthenticationProvider() {
        super();
    }
    @Autowired
    private UsuarioDAO user;

@Override
public Authentication authenticate(Authentication auth) throws AuthenticationException {
    String username = String.valueOf(auth.getName());
    String password = String.valueOf(auth.getCredentials().toString());

    Usuarios us = null;
    try {
        us = user.userAuthentication(username, password);
    } catch (Exception ex) {
    }
    if (us != null) {
        final List&lt;GrantedAuthority&gt; grantedAuths = new ArrayList&lt;&gt;();
        grantedAuths.add(new SimpleGrantedAuthority("ROLE_ADMIN"));
        final UserDetails principal = new User(username, password, grantedAuths);
        final Authentication authentication = new UsernamePasswordAuthenticationToken(principal, password, grantedAuths);
        us = null;
        return authentication;
    } else {
        throw new BadCredentialsException("Bad Credentials");
    }
}

@Override
public boolean supports(Class&lt;? extends Object&gt; authentication) {
    return (UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication));
}

}
</code></pre>

<p>Here is my WebSecurityConfiguration:</p>

<pre><code>@Configuration
@EnableWebSecurity
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {

@Override
@Bean
public AuthenticationManager authenticationManagerBean() throws Exception {
    return super.authenticationManagerBean();
}
}
</code></pre>