Java 如何解决错误不足AuthenticationException

Java 如何解决错误不足AuthenticationException,java,spring,spring-security,spring-security-oauth2,Java,Spring,Spring Security,Spring Security Oauth2,我对OAuth2有错误。我需要检索一个令牌来开始使用这个工具,以保护我的资源。我想将它集成到我所有的请求映射中 我将为授权和令牌端点添加错误。我希望有人管理了oauth2。。。非常感谢 我的OauthServerConfig: @Configuration public class OAuth2ServerConfigAuthorizationServerConfiguration { private static final String RESOURCE_ID = "restse

我对OAuth2有错误。我需要检索一个令牌来开始使用这个工具,以保护我的资源。我想将它集成到我所有的请求映射中

我将为授权和令牌端点添加错误。我希望有人管理了oauth2。。。非常感谢

我的OauthServerConfig:

@Configuration
public class OAuth2ServerConfigAuthorizationServerConfiguration {

    private static final String RESOURCE_ID = "restservice";

    @Configuration
    @EnableResourceServer
    protected static class ResourceServerConfiguration extends
            ResourceServerConfigurerAdapter {

        @Override
        public void configure(ResourceServerSecurityConfigurer resources) {
            // @formatter:off
            resources
                .resourceId(RESOURCE_ID);
            // @formatter:on
        }

        public void configure(HttpSecurity http) throws Exception {
            // @formatter:off
            http
                .authorizeRequests()
                    .antMatchers("/api/**").authenticated();
            // @formatter:on
        }

    }

    @Configuration
    @EnableAuthorizationServer
    protected static class AuthorizationServerConfiguration extends
            AuthorizationServerConfigurerAdapter {

        private TokenStore tokenStore = new InMemoryTokenStore();

        @Autowired
        @Qualifier("authenticationManagerBean")
        private AuthenticationManager authenticationManager;

        @Override
        public void configure(AuthorizationServerEndpointsConfigurer endpoints)
                throws Exception {
            // @formatter:off
            endpoints
                .tokenStore(this.tokenStore)
                .authenticationManager(this.authenticationManager);
         //   .pathMapping("/oauth/token", "/entuzona/oauth/token");
            // @formatter:on
        }

        @Override
        public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
            // @formatter:off
            clients
                .inMemory()
                    .withClient("clientapp")
                        .authorizedGrantTypes("password","refresh_token")
                        .authorities("USER")
                        .scopes("read", "write")
                        .resourceIds(RESOURCE_ID)
                        .secret("123456");
            // @formatter:on
        }

        @Bean
        @Primary
        public DefaultTokenServices tokenServices() {
            DefaultTokenServices tokenServices = new DefaultTokenServices();
            tokenServices.setSupportRefreshToken(true);
            tokenServices.setTokenStore(this.tokenStore);
            return tokenServices;
        }

    }
}
我的OauthClientConfig:

@Configuration
@ComponentScan({"com.sprhib"})
@EnableWebSecurity
@EnableWebMvcSecurity
public class OAuth2ClientConfig
  extends WebSecurityConfigurerAdapter
{
  protected void configure(AuthenticationManagerBuilder auth)
    throws Exception
  {
    auth.inMemoryAuthentication().withUser("teste").password("teste").authorities("USER");
  }

  @Bean
  public AuthenticationManager authenticationManagerBean()
    throws Exception
  {
    return super.authenticationManagerBean();
  }
}
如果我想创建/oauth/authorize/:

你知道我的要求有什么问题吗