I try to configure OpenFeign on my spring boot application, i use pokeapi to test.
i make this code:
@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);
}
But when i make this call this error happens: feign.FeignException$Forbidden: [403 Forbidden] during [GET] to [https://pokeapi.co/api/v2/pokemon/ditto] [PokeApiClient#findPokemonByName(String)]: [error code: 1010]
What should i do in this case?
I tried to configure the WebSecurity with this:
@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();
}
}