admin 管理员组

文章数量: 1086019

Struggling with this error, while I trying login via OAUTH GOOGLE.

My securityfilterchian

    @Bean
    public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
        //http.cors(cors -> cors.configurationSource(corsConfigurationSource()));
        http.cors(cors -> cors.disable());
        http.csrf(csrf ->csrf.ignoringRequestMatchers("/oauth/*", "/auth/user"));
        http.authorizeHttpRequests(request -> request.requestMatchers("/oauth/*","/auth/user").permitAll().anyRequest().authenticated());
        http.oauth2Login(login -> login.successHandler(((request, response, authentication) -> response.sendRedirect("/auth/user"))));




        return http.build();
    }

in application.properties

spring.security.oauth2.client.registration.google.client-id= my client id
spring.security.oauth2.client.registration.google.client-secret= my client secret 

Is there something else what I have to configurate ?

EDIT (SOLVED)

reason of 'Invalid credentials' was my sessions, which was 'null'. Reason of this null was automatically set up 'sameSite' cookies by this @Bean

@Bean
public CookieSameSiteSupplier applicationCookieSameSiteSupplier() {
    return CookieSameSiteSupplier.ofStrict();
}

本文标签: javaSpring security OAUTHInvalid credentialsStack Overflow