无法进行伪装请求,“ feign.FeignException $ Forbidden:[403 Forbidden]”

问题描述 投票:0回答:1

我尝试在我的Spring Boot应用程序上配置OpenFeign,我使用pokeapi进行测试。

我输入此代码:

@FeignClient(value = "pokeapi", url = "https://pokeapi.co")
public interface PokeApiClient {

@Headers("Content-Type: application/json")
@RequestMapping(method = RequestMethod.GET, value = "/api/v2/pokemon/{name}", consumes = 
"application/json")
Optional<Pokemon> findPokemonByName(@PathVariable("name") String name);

}

但是当我拨打此电话时,会发生此错误:feign.FeignException $ Forbidden:在[GET]到[https://pokeapi.co/api/v2/pokemon/ditto] [PokeApiClient#findPokemonByName(String)]期间[403禁止]:[错误代码:1010]

在这种情况下我该怎么办?

我试图以此配置WebSecurity:

@Configuration
@EnableWebSecurity
public class HttpConfiguration extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
                .csrf().disable()
                .authorizeRequests()
                .antMatchers(HttpMethod.POST, "/**/authenticate").permitAll()
                .antMatchers(HttpMethod.GET, "/**/get-public-key").permitAll()
                .antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
                .anyRequest().permitAll();
    }
}
java spring spring-boot spring-mvc spring-cloud-feign
1个回答
0
投票

禁止403表示服务器理解了请求但拒绝了授权,因此可能是权限问题。错误代码1010有时是网站所有者根据您的浏览器阻止的请求...希望这些想法对您有所帮助? :)

© www.soinside.com 2019 - 2024. All rights reserved.