I use keycloak with Spring Boot api rest, but I get this error:
Bearer error="insufficient_scope", error_description="The request requires higher privileges than provided by the access token.", error_uri="https://tools.ietf.org/html/rfc6750#section-3.1"
I believe this token is valid.
Code:
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
System.out.println("Entro a seguridad");
http.authorizeHttpRequests()
.requestMatchers("/all/**")
.hasAnyRole("user_roles")
.anyRequest()
.permitAll();
http.oauth2Login()
.and()
.logout()
.addLogoutHandler((LogoutHandler) keycloakLogoutHandler)
.logoutSuccessUrl("/");
http.oauth2ResourceServer(OAuth2ResourceServerConfigurer::jwt);
return http.build();
I expect the token works. How do I fix this error?